Repository navigation
fix(cli): clear error for empty/comment-only scenario/persona/traits YAML - #1600
Open
PratikDhanave (PratikDhanave) wants to merge 1 commit into
Open
PratikDhanave (PratikDhanave) wants to merge 1 commit into
PratikDhanave (PratikDhanave) wants to merge 1 commit into
Conversation
…s YAML loadScenario/loadPersona/loadTraits in config-loader.ts dereference the parsed YAML immediately (data.task, data.personality, ...). The yaml parser returns null for an empty or comment-only file, so 'scope run' with such a scenario/persona/traits file crashed with an opaque 'TypeError: Cannot read properties of null (reading "task")' instead of the clear validation error each loader is written to raise. Guard for a null/non-object parse result in all three loaders and raise the loader's own validation message. Add config-loader.test.ts covering the empty and comment-only cases plus a valid-scenario sanity check.
PratikDhanave (PratikDhanave)
requested review from
Cedric Vidal (cedricvidal) and
Wassim Chegham (manekinekko)
as code owners
November 1, 2026 02:00
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
scope runcrashed with an opaqueTypeErrorwhen the scenario, persona, or traits YAML file was empty or comment-only, instead of the clear validation error each loader is written to raise.In
apps/cli/src/config-loader.ts,loadScenario/loadPersona/loadTraitsdereference the parsed YAML immediately (data.task,data.personality, …). Theyamlparser returnsnullfor an empty or comment-only file, so the dereference threwTypeError: Cannot read properties of null (reading 'task')and the user never saw the intended message. This adds anull/non-object guard in all three loaders that raises each loader's own validation error.Demos
N/A — the change is a text-only CLI error message (a thrown
Error), not a visual Portal/CLI change, so a recording isn't meaningful. Before/after error text:Before
After
Testing
Added
apps/cli/src/config-loader.test.ts(empty scenario, comment-only scenario, comment-only persona, valid-scenario sanity check).pnpm exec vitest run apps/cli/src/config-loader.test.ts→ 4 passed. The empty/comment cases fail before the fix (TypeError: Cannot read properties of null) and pass after.pnpm exec vitest run apps/cli→ 16 files, 164 tests passed (no regressions).Documentation and compatibility
None. The change only replaces an uncaught
TypeErrorwith the already-documented validation error; no API/CLI flag, schema, or behavior change for valid inputs. Backward compatible.Checklist
up()/down()and keep it CosmosDB-compatible. — N/A (no DB change)NOTICE/NOTICE-REVIEW.txtwithpnpm noticeas needed. — N/A (no dependency change)Developed with AI assistance (Claude Code): the crash was located, the guards added, and the tests written and run locally (vitest). I reviewed and verified the change and take responsibility for it.