Deduplicate model multiplier parsing helpers across API proxy guards#4293
Conversation
There was a problem hiding this comment.
Pull request overview
This PR reduces duplicated parsing logic in the API proxy guard layer by centralizing shared “model multiplier” parsing helpers into guard-utils, and updating both effective-token-guard and max-model-multiplier-guard to use the shared implementation.
Changes:
- Added
parseModelMultipliers(raw)andparsePositiveNumber(raw)tocontainers/api-proxy/guards/guard-utils.jsand exported them alongsideparsePositiveInteger. - Removed the duplicated helper implementations from
effective-token-guard.jsandmax-model-multiplier-guard.js, replacing them with imports from./guard-utils. - Expanded
guard-utils.test.jsto cover invalid inputs and expected filtering/semantics for both new helpers.
Show a summary per file
| File | Description |
|---|---|
| containers/api-proxy/guards/guard-utils.js | Centralizes parseModelMultipliers and parsePositiveNumber in the shared guard utilities module. |
| containers/api-proxy/guards/guard-utils.test.js | Adds unit coverage for the newly centralized parsing helpers, including invalid and edge inputs. |
| containers/api-proxy/guards/effective-token-guard.js | Switches from inline helper copies to importing the shared parsing helpers from guard-utils. |
| containers/api-proxy/guards/max-model-multiplier-guard.js | Switches from inline helper copies to importing the shared parsing helpers from guard-utils. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/4 changed files
- Comments generated: 0
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (1 files)
Coverage comparison generated by |
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.
|
@copilot fix this failing ci check https://github.com/github/gh-aw-firewall/actions/runs/26919029512/job/79420287272?pr=4293 |
Fixed in commit |
Smoke Test: Claude Engine
Total: PASS
|
🔍 Smoke Test Results
PR: Deduplicate model multiplier parsing helpers across API proxy guards Overall: PARTIAL — MCP ✅, pre-step outputs were not expanded so HTTP/file tests could not be verified.
|
This comment has been minimized.
This comment has been minimized.
🔭 Smoke Test: API Proxy OpenTelemetry Tracing
All 5 scenarios pass. OTEL tracing integration is complete and functional.
|
|
Smoke test result: 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.
|
|
Deduplicate model multiplier parsing helpers across API proxy guards 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.
|
Chroot Version Comparison Results
Overall: ❌ Not all tests passed — Python and Node.js versions differ between host and chroot.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — PASS 🎉
|
Smoke Test: GitHub Actions Services Connectivity
Overall: FAIL —
|
Smoke Test: Copilot BYOK (Direct) — PASS
Running in direct BYOK mode (
|
Two guard modules (
effective-token-guardandmax-model-multiplier-guard) carried identical implementations ofparseModelMultipliersandparsePositiveNumber, creating duplicated production parsing logic and split maintenance risk. This change centralizes those helpers inguard-utilsand updates both guards to consume the shared exports.Shared guard parsing utilities
parseModelMultipliers(raw)andparsePositiveNumber(raw)tocontainers/api-proxy/guards/guard-utils.jsparsePositiveIntegerGuard deduplication
containers/api-proxy/guards/effective-token-guard.jscontainers/api-proxy/guards/max-model-multiplier-guard.js./guard-utilsUtility coverage
containers/api-proxy/guards/guard-utils.test.jswith focused cases for: