Skip to content

fix(repl): print every line of a usage error at the prompt - #1027

Merged
HuiJun merged 2 commits into
developfrom
devin/1791545278-repl-usage-error-lines
Oct 9, 2026
Merged

HuiJun merged 2 commits into
developfrom
devin/1791545278-repl-usage-error-lines

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What and why

The terminal prompt printed only the first line of a multi-line usage error. A repository or notebook %load, %repo, %projects or %publish given wrong arguments answers with a *repl.UsageError whose Lines hold the usage line and the line saying what was wrong; UsageError.Error() is Lines[0] alone, and repl.Loop printed "error: " + merr.Error(). So %load --id x showed the usage and dropped --id is not an option of %load, while the Jupyter kernel, which reports execError("UsageError", usage.Error(), usage.Lines), showed both.

Two conventions coexist in the meta handlers. %render, %viz and %render-document return their usage lines as output (metaRender: return usage, false, nil), so the loop already printed them whole; *UsageError there is what the typed APIs (Session.Render, Viz, RenderDocument) return to callers like the kernel. The repository and notebook commands instead return *UsageError as the meta error (usageError(...) in repository.go, parseLoadArgs in notebook.go), which is what the kernel's %projects now → UsageError test and docs/reference/jupyter-kernel.md ("a % command given wrong arguments is a UsageError whose traceback is the command's usage") rely on. Moving those handlers to the output convention would turn the kernel's UsageError into plain stdout, so the fix is on the terminal side: repl.Loop now prints every line of a *UsageError through metaErrorLines — the first under the error: prefix, as before and as the kernel's value is; the rest as they are, as the kernel's traceback shows them. Any other meta error prints as it did. UsageError.Error() is unchanged, so the kernel's output and its tests are untouched.

No other consumer loses lines: cmd/sysml reaches RunMeta only through repl.Loop, and the referee's %eval in path never produces a UsageError.

How it was verified

New TestLoopPrintsEveryLineOfAUsageError in internal/frontend/repl/repository_test.go drives %load --id x, %load --id=a --id=b and %projects now through repl.Loop and pins the exact lines. No existing test pinned the one-line terminal output; the kernel tests (internal/frontend/jupyter/{repository,replengine}_test.go) still pass unchanged.

%load --id x at the prompt, before:

sysml> %load --id x
error: usage: %load [--id=<project id>] [--name=<name>] [--branch=<branch name or id>] [<name>]

after:

sysml> %load --id x
error: usage: %load [--id=<project id>] [--name=<name>] [--branch=<branch name or id>] [<name>]
--id is not an option of %load

Gates run locally: gofmt -l . (empty), go build ./..., go vet ./..., make lint, go test -race -count=1 ./internal/frontend/repl/... ./internal/frontend/jupyter/..., go test ./..., python3 scripts/changelog.py check, python3 scripts/check-doc-ids.py.

Checklist

  • make test and make lint pass locally
  • Tests added or updated for the change
  • Documentation extended where it already covers the surface (see CONTRIBUTING.md) — the reference documents the kernel's UsageError; the prompt's output needed no new text
  • Changelog entry added as changes/unreleased/<slug>.<section>.md, not as an edit to CHANGELOG.md
  • baselines regenerated and make docs-counts run if a gate count moved (no gate count moved)
  • No internal work-item labels (waves, slices, F4, K5) in the body, docs, or changelog

A repository or notebook command given wrong arguments returns its usage as a
*UsageError, whose Error() is only the first line; the terminal loop printed
that line alone, leaving out the line saying what was wrong, while the Jupyter
kernel's traceback showed both. The loop now prints every line the error
holds, the first under the error prefix as before.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration
devin-ai-integration Bot marked this pull request as ready for review October 9, 2026 12:35

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Devin Review: 2 flags

Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

Co-Authored-By: jason.han <hanhuijun@gmail.com>
@HuiJun
HuiJun merged commit d681851 into develop Oct 9, 2026
50 of 52 checks passed
@HuiJun
HuiJun deleted the devin/1791545278-repl-usage-error-lines branch October 9, 2026 14:34
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.

1 participant