Validate Signal runtime config - #617
Conversation
Greptile SummaryThis PR adds upfront validation of
Confidence Score: 4/5Safe to merge; the validation logic is straightforward and both entry points are guarded. The two minor gaps noted are worth addressing but do not block the change. The E.164 regex lower-bound of 8 digits after Both changed files are straightforward; Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[build / ship called] --> B[requirePhoneNumber]
B -->|invalid E.164| C[throw Error]
B -->|valid| D[requireRuntime]
D -->|not in RUNTIMES| E[throw Error]
D -->|valid| F[proceed with phoneNumber + runtime]
F --> G{build?}
G -->|yes| H[write signal-runtime-plan.json]
G -->|no - ship| I{ctx.dryRun?}
I -->|yes| J[return id: dry-run]
I -->|no| K[return id: signal:phoneNumber@version]
Reviews (1): Last reviewed commit: "Validate Signal runtime config" | Re-trigger Greptile |
|
|
||
| function requirePhoneNumber(config: Config): string { | ||
| const phoneNumber = config.phoneNumber?.trim(); | ||
| if (!/^\+[1-9]\d{7,14}$/.test(phoneNumber)) { |
There was a problem hiding this comment.
The E.164 regex requires at minimum 9 characters after
+ ([1-9] plus \d{7,14}), but the ITU-T standard allows as few as 4 total digits for some assigned country codes (e.g., Niue +683XXXX = 7 digits). Any phone number with fewer than 8 digits after + will be incorrectly rejected. Lowering the lower-bound to {6,14} brings coverage down to the smallest real-world allocations while staying well within E.164's 15-digit ceiling.
| if (!/^\+[1-9]\d{7,14}$/.test(phoneNumber)) { | |
| if (!/^\+[1-9]\d{6,14}$/.test(phoneNumber)) { |
| it('rejects unsupported runtimes before dry-run shipping', async () => { | ||
| await expect(adapter.ship(fakeShipContext({ | ||
| version: '1.2.3', | ||
| dryRun: true, | ||
| }) as any, { | ||
| ...sampleConfig, | ||
| runtime: 'signal-web', | ||
| } as any)).rejects.toThrow('runtime must be one of'); | ||
| }); |
There was a problem hiding this comment.
Missing coverage:
build with invalid runtime. The new runtime-rejection test only exercises ship. Since build also calls requireRuntime directly, a counterpart test that passes an invalid runtime to build would confirm the guard fires on both entry points. Without it, a future refactor that accidentally drops the requireRuntime call from build would go undetected.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
8 similar comments
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
Fixes #616.
Changes:
Validation: