Extract shared positive-integer parsing for api-proxy guards#3565
Conversation
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (4 files)
Coverage comparison generated by |
There was a problem hiding this comment.
Pull request overview
This PR reduces duplication in the api-proxy guard layer by extracting the common “positive integer from env var” parsing logic into a shared guard utility, and refactoring existing guards to use it. It also adds focused unit coverage so any future parsing tweaks can be made (and validated) in one place.
Changes:
- Added
parsePositiveInteger(raw)to a new shared guard utility module (guard-utils.js). - Refactored
max-runs-guard,timeout-steering, andeffective-token-guardto use the shared parser instead of local copies. - Added unit tests covering accepted/rejected inputs for the shared parser.
Show a summary per file
| File | Description |
|---|---|
| containers/api-proxy/guards/guard-utils.js | Introduces shared positive-integer parsing helper for guard env/config values. |
| containers/api-proxy/guards/guard-utils.test.js | Adds unit coverage for the shared parser (with a minor test-name formatting nit). |
| containers/api-proxy/guards/max-runs-guard.js | Replaces inline max-runs parsing with the shared helper. |
| containers/api-proxy/guards/timeout-steering.js | Replaces inline timeout-minutes parsing with the shared helper. |
| containers/api-proxy/guards/effective-token-guard.js | Replaces inline max-effective-tokens parsing with the shared helper. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 5/5 changed files
- Comments generated: 1
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Smoke Test Results✅ GitHub API: 2 PR entries confirmed Result: PASS
|
🤖 Smoke Test Results
PR: "Extract shared positive-integer parsing for api-proxy guards" Overall: PARTIAL — MCP ✅, pre-step smoke data not injected into workflow
|
🔥 Smoke Test: Copilot BYOK (Offline) Mode
Running in BYOK offline mode ( PR author: Overall: PASS (core BYOK path confirmed ✅)
|
|
Smoke Test Codex: FAIL Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
Smoke Test: API Proxy OpenTelemetry Tracing
All 5 scenarios passed. OTEL tracing integration is working correctly.
|
Chroot Version Comparison
Result: Not all tests passed. Python and Node.js versions differ between host and chroot environments.
|
Smoke Test Results
Overall status: FAIL Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "localhost"See Network Configuration for more information.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
Smoke Test Results — FAIL
|
Three api-proxy guard modules each carried the same env-var parsing logic for positive integers, creating avoidable duplication and a three-place maintenance surface. This change consolidates that behavior behind a single guard utility and updates the affected guards to consume it.
Shared guard utility
containers/api-proxy/guards/guard-utils.jswithparsePositiveInteger(raw)nullfor absent/blank/non-integer/<= 0, parsed integer otherwiseGuard refactor
max-runs-guard.jstimeout-steering.jseffective-token-guard.jsFocused coverage
containers/api-proxy/guards/guard-utils.test.jsExample: