Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/cli/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ export const myRoute = buildRouteMap({
### Positional Arguments

Required identifiers (trace IDs, span IDs) should be **positional args**, not
flags. Every command that takes trace, span, replay, or log IDs parses them
with `parseIdArguments` (or `parseIdArgument` for exactly one) from
flags. Every command that takes trace, span, replay, log, or event IDs parses
them with `parseIdArguments` (or `parseIdArgument` for exactly one) from
`src/lib/id-arguments.ts`, so they all take the same forms:

- `<id>`, `<org>/<id>`, `<org>/<project>/<id>`, `<target> <id>`, a Sentry URL
Expand All @@ -248,8 +248,8 @@ target is known. The result is a `target` string for `parseOrgProjectInput`
and the IDs. Add a kind to `ID_KINDS` rather than validating IDs in a command;
the `sentry-cli/no-ad-hoc-id-arguments` lint rule rejects hand-written ID
parsing (`parseSlashSeparatedArg`, `HEX_ID_RE`, ...) in commands and kinds
defined outside `ID_KINDS`. Issue IDs (and `event view`, which takes them)
keep their own syntax.
defined outside `ID_KINDS`. Issue IDs keep their own syntax; `event view`,
which also takes them, checks for an issue first (`parseEventViewInput`).

**Issue positionals:** issue IDs, short IDs, selectors, and issue URLs are
parsed by `parseIssueArgument` (`src/lib/issue-arguments.ts`), whose forms
Expand Down Expand Up @@ -328,7 +328,7 @@ command's help instead. The same purity rule applies: return a pasted URL's serv
(`baseUrl`) and any warnings from the parse, and apply them in `resolve`
(`parseTraceTargetInput` and `parseDualModeInput` in `trace-target.ts` do
this for trace targets). Commands that recover a malformed ID (`trace view`,
`span view`, `log view`) parse it unvalidated and validate or recover it in
`span view`, `log view`, `event view`) parse it unvalidated and validate or recover it in
`resolve`, which can look the prefix up: `parseTraceArgumentsInput` and
`resolveTraceArguments` do this for trace IDs. A missing ID or a bad target
still fails the parse.
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/grammar/id-arguments.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ arguments
}
// Any other URL is a target
/ sep t:url x:more { return { target: t, ids: x }; }
// `<id> <org>/<project>`: the arguments are reversed. When IDs are
// optional, only a real ID can come first.
// `<id> <org>/<project> [<id>...]`: the arguments are reversed. When IDs
// are optional, only a real ID can come first.
/ sep i:segment &{ return !optional || isId(i); } sep !idPath
t:$([^/\0]* "/" [^\0]*) end
{ return { target: t, ids: [{ text: i, id: i }], reversed: true }; }
t:$([^/\0]* "/" [^\0]*) x:more
{ return { target: t, ids: [{ text: i, id: i }, ...x], reversed: true }; }
// `[<org>/[<project>/]]<id> [<id>...]`
/ sep p:idPath x:more {
return {
Expand Down
11 changes: 2 additions & 9 deletions packages/cli/lint-rules/cli-oxlint-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const BOUND_TARGET_TYPES = new Set([
"OrgProjectTarget",
"ProjectBoundTarget",
"BoundArguments",
"EventViewArguments",
"LogListArguments",
"LogViewArguments",
"ReplayArguments",
Expand Down Expand Up @@ -165,12 +166,6 @@ const AD_HOC_ID_PARSING = new Set([
"SPAN_ID_RE",
]);

/**
* Commands still allowed to: `event view` also takes issue IDs, which are
* not hex IDs and have their own syntax.
*/
const AD_HOC_ID_PARSING_ALLOWED = ["/src/commands/event/view.ts"];

const ID_ARGUMENT_PARSERS = new Set(["parseIdArguments", "parseIdArgument"]);

/** Whether `node` is `ID_KINDS.<kind>`. */
Expand Down Expand Up @@ -355,9 +350,7 @@ const rules = {
(_context, file, report) => {
if (!file.includes("/src/") || file.endsWith("/lib/id-arguments.ts"))
return {};
const commands =
file.includes("/src/commands/") &&
!AD_HOC_ID_PARSING_ALLOWED.some((allowed) => file.endsWith(allowed));
const commands = file.includes("/src/commands/");
return {
Identifier(node) {
if (
Expand Down
Loading
Loading