Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/lu/src/parser/lufile/parseFileContents.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,16 +437,17 @@ const parseFeatureSections = function(parsedContent, featuresToProcess) {
// We are only interested in extracting features and setting things up here.
(featuresToProcess || []).forEach(section => {
if (section.Type === INTENTTYPE) {
// verify intent exists
if (!section.Features || section.Roles) {
// Intents can only have features and nothing else.
// Intents can only have features and nothing else.
if (section.Roles) {
let errorMsg = `Intents can only have usesFeature and nothing else. Invalid definition for "${section.Name}".`;
let error = BuildDiagnostic({
message: errorMsg,
context: section.ParseTree.newEntityDefinition().newEntityLine()
})
throw (new exception(retCode.errorCode.INVALID_INPUT, error.toString(), [error]));
}
if (!section.Features) return;
// verify intent exists
section.Name = section.Name.replace(/[\'\"]/g, "");
let intentExists = parsedContent.LUISJsonStructure.intents.find(item => item.name === section.Name);
if (intentExists !== undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ describe('Model as feature definitions', function () {
.catch(err => done())
});

it('Intent can only have features and nothing else empty throws', function (done) {
it('Intent can have empty uses feature assignment line', function (done) {
let luFile = `
@ intent xyz
## None
- all of them
- i want them all
- i want to all of them

@ intent None
`;

parseFile.parseFile(luFile)
.then(res => done(res))
.catch(err => done())
.then(res => done())
.catch(err => done(err))
});

it('Intent must be defined before a feature can be added to it.', function(done) {
Expand Down Expand Up @@ -849,4 +854,4 @@ describe('Model as feature definitions', function () {
})

})
});
});