Skip to content

fix(miner): reject a portfolio-queue identifier containing the '::' composite-id separator (#8857) - #8925

Merged
loopover-orb[bot] merged 2 commits into
JSONbored:mainfrom
RealDiligent:fix/critical-issue-queueitem-id-separator-8857
Jul 26, 2026
Merged

fix(miner): reject a portfolio-queue identifier containing the '::' composite-id separator (#8857)#8925
loopover-orb[bot] merged 2 commits into
JSONbored:mainfrom
RealDiligent:fix/critical-issue-queueitem-id-separator-8857

Conversation

@RealDiligent

Copy link
Copy Markdown
Contributor

Problem

Closes #8857.

portfolio-queue-manager.ts's queueItemId joins apiBaseUrl::repoFullName::identifier on :: (ITEM_ID_SEPARATOR), and parseQueueItemId splits from the last two ::. repoFullName is guaranteed ::-free (isValidRepoSegment), but identifier (normalizeIdentifier) had no such guard. So queueItemId('https://api.github.com', 'acme/widgets', 'issue::5') parses back as { apiBaseUrl: 'https://api.github.com::acme/widgets', repoFullName: 'issue', identifier: '5' } — silently corrupted. Nothing enforced the invariant.

Fix

Reject any identifier containing the literal :: substring in normalizeIdentifier, throwing invalid_identifier at construction rather than allowing silent downstream corruption (the issue's preferred reject-the-invariant approach, not encoding).

Tests

  • queueItemId/parseQueueItemId round-trip an identifier that does not contain :: (single-colon issue:5).
  • Enqueue with issue::5 throws invalid_identifier; issue:5 is still accepted.

Reverting the guard fails the rejection test. git diff --check clean.

@RealDiligent
RealDiligent requested a review from JSONbored as a code owner July 26, 2026 13:34
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.61%. Comparing base (4dfe15d) to head (ad25f33).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8925      +/-   ##
==========================================
+ Coverage   90.56%   90.61%   +0.05%     
==========================================
  Files          96       97       +1     
  Lines       22490    22611     +121     
  Branches     3884     3911      +27     
==========================================
+ Hits        20367    20488     +121     
  Misses       1945     1945              
  Partials      178      178              
Flag Coverage Δ
backend 100.00% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/loopover-miner/lib/portfolio-queue.ts 100.00% <100.00%> (ø)

…omposite-id separator

portfolio-queue-manager's queueItemId joins apiBaseUrl/repoFullName/identifier on '::' (ITEM_ID_SEPARATOR).
repoFullName is '::'-free via isValidRepoSegment, but normalizeIdentifier had no such guard, so an identifier
like 'issue::5' silently corrupted the parsed triple (e.g. queueItemId(base, 'acme/widgets', 'issue::5')
parsed back as repoFullName 'issue', identifier '5'). Reject a '::'-containing identifier at construction
(normalizeIdentifier) rather than encode-and-hope.

Tests: round-trip a valid (single-colon) identifier; enqueue with 'issue::5' throws invalid_identifier while
'issue:5' is still accepted.
@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 26, 2026
@loopover-orb

loopover-orb Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-26 14:18:19 UTC

2 files · 1 AI reviewer · no blockers · readiness 93/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This closes #8857 by rejecting any identifier containing the literal '::' substring in normalizeIdentifier (portfolio-queue.ts:113-119), preventing queueItemId's composite id from silently misparsing an identifier that itself contains the '::' join separator. The fix is applied at the correct layer (source/construction time, in normalizeIdentifier, which is the shared choke point for enqueue and every lookup path), matching the issue's stated preferred approach of reject-over-encode. Tests correctly verify both that a benign single-colon identifier round-trips and that a '::'-containing identifier throws at enqueue time via the manager, exercising the real path rather than a fabricated one.

Nits — 3 non-blocking
  • The PR lacks any behavior for reclaimStuckItem/requeueItem/markDone/markFailed paths that also call normalizeIdentifier with a pre-existing '::' identifier already persisted in an older DB — not a blocker since this is a forward-looking construction guard, but worth confirming there's no migration concern for already-stored corrupt rows.
  • The inline comment in portfolio-queue.ts:115-118 is a bit long for a one-line guard; could be trimmed since the PR description already explains the rationale.
  • Consider whether existing rows persisted before this fix (with a literal '::' in identifier) should be handled by a data migration or documented as a known gap, since normalizeIdentifier now throws on read paths (markDone/markFailed/etc.) for such rows too.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #8857
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 309 registered-repo PR(s), 124 merged, 37 issue(s).
Contributor context ✅ Confirmed Gittensor contributor RealDiligent; Gittensor profile; 309 PR(s), 37 issue(s).
Improvement ✅ Minor risk: clean · value: minor
Linked issue satisfaction

Addressed
normalizeIdentifier now throws invalid_identifier when the identifier contains "::", matching the issue's preferred reject-outright approach, and the PR adds both the required regression test (round-trip for a non-"::" identifier) and a rejection test for an identifier containing "::".

Review context
  • Author: RealDiligent
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, Ruby, TypeScript, Svelte, Cuda, JavaScript, Markdown, MDX
  • Official Gittensor activity: 309 PR(s), 37 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Triage stale or unlinked PRs.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask 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.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

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.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoopOver approves — the gate is satisfied and CI is green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(miner): queueItemId/parseQueueItemId corrupts round-trip when identifier contains "::"

1 participant