Commit e3ca859
authored
## Summary
- Add `validateHexId()` to event view command, matching trace/log view
behavior — malformed event IDs are now caught before making API calls
- Add flag-like string detection in `validateHexId()` — inputs starting
with `-` (e.g., `--h`, `--verbose`) produce a targeted hint instead of
the generic "doesn't look like a hex ID" message
- Extend `maybeRecoverWithHelp` to recognize `--h` and `-help` as
help-seeking tokens, showing actual help output on error
Fixes [CLI-156](https://sentry.sentry.io/issues/7410782826/)
## Context
When a user types `sentry event --h` (a common typo for `--help` or
`-h`), Stricli doesn't recognize `--h` as a help flag — it only handles
`--help` and `-h`. Its long-flag regex also requires 2+ chars after
`--`, so `--h` isn't treated as a flag at all. It falls through as a
positional argument to `event view` (the default command). Unlike `trace
view` and `log view` which call `validateHexId()`, event view had no
format validation before API calls, so `--h` was sent as an event ID,
producing a confusing `ResolutionError: Event '--h' not found`.
## Changes
| File | Change |
|------|--------|
| `src/lib/hex-id.ts` | New `FLAG_LIKE_RE`/`HELP_FLAG_RE` regexes;
flag-like detection branch before existing span-ID and slug hints |
| `src/commands/event/view.ts` | `validateHexId(eventId, "event ID")` in
`func()` after parsing, before resolution; skips sentinels from issue
URL/short ID paths |
| `src/lib/command.ts` | `maybeRecoverWithHelp` now also matches `"--h"`
and `"-help"` in positional args |
| `test/lib/hex-id.test.ts` | 4 new tests for flag-like detection (help
hint, generic flag hint, precedence over slug hint) |
| `test/commands/event/view.test.ts` | 2 new `viewCommand.func` tests
for `--h` and non-hex IDs; updated existing func tests to use valid
32-char hex IDs |
1 parent dff7cad commit e3ca859
File tree
6 files changed
+138
-14
lines changed- src
- commands/event
- lib
- test
- commands/event
- e2e
- lib
6 files changed
+138
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
737 | 737 | | |
738 | 738 | | |
739 | 739 | | |
740 | | - | |
| 740 | + | |
741 | 741 | | |
742 | 742 | | |
743 | 743 | | |
744 | 744 | | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
745 | 754 | | |
746 | 755 | | |
747 | 756 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
485 | 485 | | |
486 | 486 | | |
487 | 487 | | |
488 | | - | |
489 | | - | |
| 488 | + | |
| 489 | + | |
490 | 490 | | |
491 | 491 | | |
492 | 492 | | |
| |||
511 | 511 | | |
512 | 512 | | |
513 | 513 | | |
514 | | - | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
515 | 518 | | |
516 | 519 | | |
517 | 520 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
30 | 36 | | |
31 | 37 | | |
32 | 38 | | |
| |||
77 | 83 | | |
78 | 84 | | |
79 | 85 | | |
80 | | - | |
81 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
82 | 98 | | |
83 | 99 | | |
84 | 100 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
787 | 787 | | |
788 | 788 | | |
789 | 789 | | |
| 790 | + | |
790 | 791 | | |
791 | | - | |
| 792 | + | |
792 | 793 | | |
793 | 794 | | |
794 | 795 | | |
| |||
833 | 834 | | |
834 | 835 | | |
835 | 836 | | |
836 | | - | |
| 837 | + | |
837 | 838 | | |
838 | 839 | | |
839 | 840 | | |
840 | | - | |
| 841 | + | |
841 | 842 | | |
842 | 843 | | |
843 | 844 | | |
| |||
904 | 905 | | |
905 | 906 | | |
906 | 907 | | |
907 | | - | |
| 908 | + | |
908 | 909 | | |
909 | 910 | | |
910 | 911 | | |
911 | 912 | | |
912 | 913 | | |
913 | 914 | | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
914 | 947 | | |
915 | 948 | | |
916 | 949 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
66 | 70 | | |
67 | 71 | | |
68 | 72 | | |
69 | 73 | | |
70 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
71 | 86 | | |
72 | 87 | | |
73 | 88 | | |
| |||
76 | 91 | | |
77 | 92 | | |
78 | 93 | | |
79 | | - | |
| 94 | + | |
80 | 95 | | |
81 | 96 | | |
82 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
139 | 187 | | |
140 | 188 | | |
141 | 189 | | |
| |||
0 commit comments