Conversation
- Simplify startMs parsing: replace parseInt+isFinite with Number()+isFinite
- Add test for partial number string edge case ('123abc' → startMs=0)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Hey However, this repository does not have a
|
There was a problem hiding this comment.
Pull request overview
Cleans up action_setup_otlp.cjs by adjusting how SETUP_START_MS is parsed and adds a regression test to document the stricter behavior for partial numeric strings.
Changes:
- Updated
SETUP_START_MSparsing to useNumber()+Number.isFiniteand default to0when invalid. - Added a test case asserting that partial numeric strings like
"123abc"result instartMs=0.
Show a summary per file
| File | Description |
|---|---|
| actions/setup/js/action_setup_otlp.cjs | Changes SETUP_START_MS parsing logic before passing startMs into sendJobSetupSpan. |
| actions/setup/js/action_setup_otlp.test.cjs | Adds coverage for partial-number SETUP_START_MS input ("123abc"). |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
| const rawMs = Number(process.env.SETUP_START_MS); | ||
| const startMs = Number.isFinite(rawMs) ? rawMs : 0; |
There was a problem hiding this comment.
Number(process.env.SETUP_START_MS) changes the accepted formats compared to the previous parseInt(..., 10): it will treat strings like "1e3" as 1000 and "0x10" as 16 (and it will accept decimals), which can silently produce an unexpected epoch-ms value. If SETUP_START_MS is intended to be a base-10 integer timestamp, consider validating the env var as a decimal-integer string (optionally trimmed) and only then converting (e.g., also requiring Number.isSafeInteger), otherwise fall back to 0.
🧪 Test Quality Sentinel ReportTest Quality Score: 80/100✅ Excellent
Test Classification Details
Flagged Tests — Requires ReviewNo tests require mandatory review. One minor note: i️ Test Inflation Ratio (informational, not blocking)The test file adds 8 lines vs. 2 production lines (4:1 ratio), which technically exceeds the 2:1 threshold. However, this is contextually reasonable: the single new test verifies a subtle but important behavioral difference between Language SupportTests analyzed:
Verdict
📖 Understanding Test ClassificationsDesign Tests (High Value) verify what the system does:
Implementation Tests (Low Value) verify how the system does it:
Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators. References: §24998136103
|
|
@copilot review all comments |
Use /^\d+$/ regex + Number.isSafeInteger to ensure only plain decimal-integer strings are accepted. Rejects '1e3', '0x10', '1.5', '-1', '123abc', etc. Adds two new tests to document the stricter behaviour. Agent-Logs-Url: https://github.com/github/gh-aw/sessions/ca363e52-dba5-4de1-8c73-4d454325531d Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Addressed in c584709. The parsing now uses |
Summary
Cleaned
action_setup_otlp.cjs— a Node.js context file (not github-script).Changes
action_setup_otlp.cjsSETUP_START_MSparsing: replacedparseInt(..., 10)+Number.isFinitewith the cleanerNumber()+Number.isFinitepattern — removes the unnecessary|| "0"fallback and is more semantically precise (rejects partial strings like"123abc"instead of parsing123)action_setup_otlp.test.cjs"should pass startMs=0 when SETUP_START_MS is a partial number string like '123abc'"— documents the new strict parsing behavior (was previously silently parsing123viaparseInt)Test improvements
Context
github/coreglobals)@ts-nocheck: file already had@ts-checkenabledValidation ✅
npm run format:cjs✓npm run lint:cjs✓npm run typecheck✓action_setup_otlp.test.cjspass ✓