fix(review): make resolveInlineCommentAnchor enforce its own no-422 contract#8455
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
…ontract The fallback branch returned a single-line anchor built from start whenever the full-range check failed, without ever verifying start itself is a commentable RIGHT-side line -- so an un-postable anchor was returned as if it were the documented fail-safe. It held only because selectAnchoredInlineFindings pre-filters on that same line, an undocumented precondition this exported, independently-tested pure function neither enforced nor mentioned. Adds an anchorable flag, false only when start is not a valid RIGHT-side line, and has selectInlineComments drop such findings instead of trusting the pre-filter alone. No behavior change for any finding whose start line is valid. Closes JSONbored#8352
The 'changes' job runs git diff --check, which flags a CR at the end of any added line. inline-comment-range.ts and its test are committed with CRLF, so matching their existing endings made every line this PR adds fail that check. Added lines now use LF (untouched lines keep their existing endings, so the diff stays minimal); no content change.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8455 +/- ##
==========================================
- Coverage 92.47% 89.60% -2.87%
==========================================
Files 791 99 -692
Lines 79321 22761 -56560
Branches 23954 3891 -20063
==========================================
- Hits 73355 20396 -52959
+ Misses 4839 2187 -2652
+ Partials 1127 178 -949
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Warning ⏸️ LoopOver review result - manual review recommendedReview updated: 2026-07-24 15:48:39 UTC
Review summary Nits — 5 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
Summary
resolveInlineCommentAnchor(src/review/inline-comment-range.ts) documents a "fail-safe, no 422" guarantee, but its fallback branch did not enforce it:Whenever the full-range check failed it returned
startas a single-line anchor unconditionally, never separately checkingvalidLines.has(start). So an un-postable line was handed back as if it were the safe anchor — the function's own existing test made this visible, returning{start: 1, end: 1, multiLine: false}for a path that was never validated at all (emptyMap()).This was safe in production only because the one caller chain (
selectInlineComments→selectAnchoredInlineFindings→anchorableInlineFindings) pre-filters findings onvalidLines.has(finding.line)first — an undocumented precondition that this exported, independently-tested "pure" function neither enforced nor mentioned.Changes
anchorable: boolean, setfalseonly whenstartitself is not a valid RIGHT-side line (!validLines || !validLines.has(start)),trueon both the single-line and multi-line success paths.selectInlineComments(src/review/inline-comments.ts) now honorsanchorableand skips such findings, instead of relying solely on its own pre-filter. (grep -rn resolveInlineCommentAnchor src/confirmsinline-comments.tsis the only call site;inline-comments-select.tsreaches it only through that chain.)startline is valid — every existing case keeps its exact anchor, now withanchorable: true.Closes #8352
Notes on two judgment calls
1. The caller-side guard is unreachable today, so it carries a
v8 ignore.parseInlineLineRangesetsstart = finding.line, and the pre-filter already requiresvalidLines.has(finding.line)— so!anchor.anchorablecannot currently be hit throughselectInlineComments. Left un-ignored it is a permanently-uncovered branch that would failcodecov/patch. I marked it with this repo's established convention for exactly this situation (/* v8 ignore next -- <why unreachable> */, used 45× inroutes.tsalone) and documented why it exists: so a future selection change cannot silently reintroduce the 422. I did not delete the guard, which the issue explicitly requires.2. Line endings.
inline-comment-range.tsand its test are committed with CRLF whileinline-comments.tsis LF (git cat-file -p origin/main:<file>). My first push matched each file's committed endings, which failed thechangesjob — it runsgit diff --check, and that flags a CR at the end of every added line. Corrected: added lines now use LF, untouched lines keep their existing endings, so the diff stays minimal (30/15/46 lines) andgit diff --checkis clean. No content changed between those two pushes.Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Closes #123) — a linked open issue is required for every contributor PR.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocally;codecov/patchrequires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
src/review/**and one root test, soactionlint(no workflow change),build:mcp/test:mcp-pack(no MCP change),ui:*(no UI/OpenAPI change),test:workers(no worker change), andnpm audit(no dependency change) are not exercised by it.vitest run --coverage --coverage.all=false) — zero uncovered lines or branches across both changed source files.inline-comment-range.test.ts+inline-comments.test.tspass in full (54 tests; 67 includinginline-comments-select.test.ts), and roottsc --noEmitis clean.validLines.has(start)check makes both new cases fail, restoring it makes them pass.Safety
UI Evidencesection below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository.UI Evidence
Not applicable — backend anchor-resolution fix in
src/review/; no visible UI, frontend, docs, or extension change.