Skip to content

Fix CommandFailed not emitted when project/document validation fails - #437

Merged
BenjaminMichaelis merged 2 commits into
dependabot/npm_and_yarn/src/microsoft-trydotnet-editor/microsoft/polyglot-notebooks-1.0.740304from
copilot/fix-failing-github-actions-job
Aug 15, 2026
Merged

Fix CommandFailed not emitted when project/document validation fails#437
BenjaminMichaelis merged 2 commits into
dependabot/npm_and_yarn/src/microsoft-trydotnet-editor/microsoft/polyglot-notebooks-1.0.740304from
copilot/fix-failing-github-actions-job

Conversation

Copilot AI commented Aug 15, 2026

Copy link
Copy Markdown

@microsoft/polyglot-notebooks changed its command dispatch so errors thrown inside handlers are now swallowed via .catch() rather than propagated to context.fail(). This broke all guard checks in ProjectKernel — e.g. sending OpenDocument without an open project silently succeeded instead of emitting a CommandFailed event.

Changes

  • src/projectKernel.ts — Replace all throw new Error(...) guard patterns with explicit commandInvocation.context.fail(message); return; in every command handler (SubmitCode, OpenDocument, RequestDiagnostics, RequestCompletions, RequestHoverText, RequestSignatureHelp)
  • Remove now-dead throwIfProjectIsNotOpened() and throwIffDocumentIsNotOpened() methods

Before:

handle: (commandInvocation) => {
  this.throwIfProjectIsNotOpened(); // thrown error gets swallowed by library
  return this.handleSubmitCode(commandInvocation);
}

After:

handle: (commandInvocation) => {
  if (!this._project) {
    commandInvocation.context.fail(`Project must be opened, send the command '${polyglotNotebooks.OpenProjectType}' first.`);
    return Promise.resolve();
  }
  return this.handleSubmitCode(commandInvocation);
}

The @microsoft/polyglot-notebooks library changed behavior so that errors
thrown inside command handlers are now swallowed via .catch() instead of
being passed to context.fail(). This caused the 'cannot open document if
there is no open project' test to fail because no CommandFailed event was
emitted.

Fix by replacing throw calls with explicit context.fail() calls in all
command handlers in projectKernel.ts.

Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix failing GitHub Actions job by identifying root cause Fix CommandFailed not emitted when project/document validation fails Aug 15, 2026
@BenjaminMichaelis
BenjaminMichaelis marked this pull request as ready for review August 15, 2026 13:40
@BenjaminMichaelis
BenjaminMichaelis merged commit 0dff50f into dependabot/npm_and_yarn/src/microsoft-trydotnet-editor/microsoft/polyglot-notebooks-1.0.740304 Aug 15, 2026
1 check passed
@BenjaminMichaelis
BenjaminMichaelis deleted the copilot/fix-failing-github-actions-job branch August 15, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants