-
-
Notifications
You must be signed in to change notification settings - Fork 10
fix(log): handle org/log-id shorthand to prevent ContextError #1222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,11 @@ | |
| import { formatLogDetails } from "../../lib/formatters/index.js"; | ||
| import { filterFields } from "../../lib/formatters/json.js"; | ||
| import { CommandOutput } from "../../lib/formatters/output.js"; | ||
| import { ageInDaysFromUuidV7, validateHexId } from "../../lib/hex-id.js"; | ||
| import { | ||
|
Check warning on line 30 in src/commands/log/view.ts
|
||
| ageInDaysFromUuidV7, | ||
| tryNormalizeHexId, | ||
| validateHexId, | ||
| } from "../../lib/hex-id.js"; | ||
| import { | ||
| handleRecoveryResult, | ||
| recoverHexId, | ||
|
|
@@ -101,6 +105,20 @@ | |
| if (args.length === 1) { | ||
| // Single arg — could be slash-separated org/project/logId or a plain ID | ||
| // (possibly containing newlines) | ||
|
|
||
| // Handle <org>/<log-id> shorthand — must check before parseSlashSeparatedArg | ||
| // because a single-slash arg is interpreted as org/project with a missing ID, | ||
| // causing a ContextError. Mirrors the pattern in replay/view.ts and event/view.ts. | ||
| const slashIdx = first.indexOf("/"); | ||
| if (slashIdx !== -1 && first.indexOf("/", slashIdx + 1) === -1) { | ||
| const org = first.slice(0, slashIdx); | ||
| const logSegment = first.slice(slashIdx + 1); | ||
| const normalizedLogId = logSegment && tryNormalizeHexId(logSegment); | ||
| if (normalizedLogId) { | ||
| return { rawLogIds: [normalizedLogId], targetArg: `${org}/` }; | ||
|
Check warning on line 118 in src/commands/log/view.ts
|
||
| } | ||
|
Comment on lines
+117
to
+119
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The new Suggested FixThe Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
| } | ||
|
|
||
| const { id, targetArg } = parseSlashSeparatedArg( | ||
| first, | ||
| "Log ID", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Org log shorthand hits project error
Medium Severity
Single-argument
org/log-idshorthand now setstargetArgto`${org}/`, whichparseOrgProjectArgtreats as org-all.resolveTargetalways rejects org-all for log view, so the command still fails for the exact input this PR targets—only theContextErrormessage changes from “Log ID” to “Specific project”.Additional Locations (1)
src/commands/log/view.ts#L254-L256Reviewed by Cursor Bugbot for commit bac9428. Configure here.