[jsweep] Clean validate_secrets.cjs#46129
Conversation
Replace verbose try/catch blocks that only transform AbortError and rethrow everything else with a concise .catch() chain on the fetch promise in both makeRequest and makePostRequest. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
|
Hey One thing worth addressing before this lands:
If you would like a hand, you can assign this prompt to your coding agent:
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅ |
|
|
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. No ADR enforcement needed: PR #46129 does not have the 'implementation' label and has 0 new lines of code in business logic directories (threshold: 100). |
|
✅ Test Quality Sentinel completed test quality analysis. No test files were added or modified in this PR. Test Quality Sentinel skipped. |
There was a problem hiding this comment.
Pull request overview
Refactors HTTP helpers while preserving timeout error handling.
Changes:
- Replaces
try/catchblocks with promise catches. - Retains response parsing and return structures.
Show a summary per file
| File | Description |
|---|---|
actions/setup/js/validate_secrets.cjs |
Simplifies GET and POST request error handling. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 2
- Review effort level: Medium
| }).catch(err => { | ||
| throw err instanceof Error && err.name === "AbortError" ? new Error("Request timeout") : err; | ||
| }); | ||
| const data = await res.text(); |
| }).catch(err => { | ||
| throw err instanceof Error && err.name === "AbortError" ? new Error("Request timeout") : err; | ||
| }); | ||
| const data = await res.text(); |
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /codebase-design — the refactor is clean and the behaviour is preserved.
📋 Key Themes & Highlights
Positive Highlights
- ✅ Duplication eliminated: the identical try/catch pattern across both functions is gone
- ✅ The AbortError → "Request timeout" transformation is correctly preserved
- ✅ All 35 tests pass; validation steps documented in the PR description
Minor Observation
The original try/catch wrapped both fetch() and res.text() together, so an AbortError thrown from res.text() would also have been caught and mapped. The new .catch() is scoped only to the fetch() call, so a hypothetical AbortError from res.text() would now propagate unmapped. In practice res.text() will never throw an AbortError after the signal fires (the fetch has already settled), so the observable behaviour is identical. Worth knowing, not worth blocking.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 10.2 AIC · ⌖ 4.34 AIC · ⊞ 6.7K
Comment /matt to run again
There was a problem hiding this comment.
Clean refactor — semantically equivalent. The .catch() chain on fetch() correctly captures AbortError (which only fetch() throws, not res.text()), so no error handling is lost.
🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · 9.45 AIC · ⌖ 4.89 AIC · ⊞ 5K
Summary
Cleaned
actions/setup/js/validate_secrets.cjsby removing unnecessary try/catch boilerplate in the HTTP helper functions.Changes
File:
validate_secrets.cjsContext:
github-scriptRemoved unnecessary try/catch blocks
Both
makeRequestandmakePostRequesthad identical try/catch patterns:Replaced with a
.catch()chain on the fetch promise:This eliminates the rethrow-only branches while preserving the AbortError → "Request timeout" transformation.
Test improvements
Existing tests already cover the timeout/abort path — all 35 tests in
validate_secrets.test.cjspass.✅ Validation
npm run format:cjs✓npm run lint:cjs✓npm run typecheck✓npm run test:js✓ (35 tests passed; pre-existing unrelated failures insend_otlp_span.test.cjsandsetup_threat_detection.test.cjsare not caused by this change)Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
traces.example.comSee Network Configuration for more information.