diff --git a/packages/lu/src/parser/lufile/parseFileContents.js b/packages/lu/src/parser/lufile/parseFileContents.js index 1512674a9..8030b4878 100644 --- a/packages/lu/src/parser/lufile/parseFileContents.js +++ b/packages/lu/src/parser/lufile/parseFileContents.js @@ -437,9 +437,8 @@ 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, @@ -447,6 +446,8 @@ const parseFeatureSections = function(parsedContent, featuresToProcess) { }) 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) { diff --git a/packages/lu/test/parser/lufile/parseFileContents.modelAsFeature.test.js b/packages/lu/test/parser/lufile/parseFileContents.modelAsFeature.test.js index 301261ede..c4b72cf3b 100644 --- a/packages/lu/test/parser/lufile/parseFileContents.modelAsFeature.test.js +++ b/packages/lu/test/parser/lufile/parseFileContents.modelAsFeature.test.js @@ -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) { @@ -849,4 +854,4 @@ describe('Model as feature definitions', function () { }) }) -}); \ No newline at end of file +});