Commit 0b87e26
Update apps/cli-e2e-tests/src/helpers/gateways/PackmindHttpClient.ts
Unguarded JSON.parse and missing decoded.jwt guard
JSON.parse(Buffer.from(this.apiKey, 'base64').toString('utf-8')) has no error handling. If the API key is not valid base64-encoded JSON (e.g. a plain token), this throws a raw SyntaxError with a confusing message before even reaching the !orgId guard that was added to handle failures gracefully.
Additionally, if the parsed JSON doesn't have a jwt field, decoded.jwt is undefined. Calling this.decodeJwt(undefined) then immediately throws a TypeError: Cannot read properties of undefined (reading 'split') at line 56 — again bypassing the explicit !orgId guard and producing an opaque error.
Wrapping the entire parsing block in a try-catch gives a single clear error message for all failure modes:
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>1 parent 229c281 commit 0b87e26
1 file changed
Lines changed: 17 additions & 9 deletions
Lines changed: 17 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
50 | 59 | | |
51 | | - | |
52 | 60 | | |
53 | 61 | | |
54 | 62 | | |
| |||
0 commit comments