Repository navigation
fix(cli): route models remove through the shared slug relation - #2596
Conversation
slugEquals compares the raw and encoded spellings of ONE id, so a removal selector written in the native slash form matched only the slash row while the encoded form matched both. Catalog filtering and persisted sync had already agreed on the collision class through slugEquivalenceKey; this command disagreed with both on the same config, which is the inconsistency #2491 reports. Removal now resolves through resolveSlugSelection, so all three surfaces see the same collision. Behaviour on an ambiguous selector is unchanged and deliberately so: it still refuses, which is the right default for a destructive command - the widening makes it refuse in a case where it previously deleted a row silently. Driven red: with the narrow exact-only relation, 3 of the 21 cases fail.
|
✅ Deterministic PR hygiene checks passed. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughCustom-model removal now uses shared slug resolution for slash-form selectors. CLI tests cover collisions between native and encoded selectors, plus successful removal for unambiguous selectors. ChangesCustom model removal
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 51fd817861
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!target.includes("/")) return model.id === target ? [index] : []; | ||
| const resolved = resolveSlugSelection(model.provider, target, [model.modelId]); | ||
| return resolved.matched.length > 0 ? [index] : []; |
There was a problem hiding this comment.
Restrict slug resolution to the selected provider
When ocx models remove wanted/x --yes is used and wanted has no matching custom row, a custom model under another provider whose ID is wanted/x or wanted-x is matched here: resolveSlugSelection treats a selector not prefixed by the current model's provider as a bare native ID. The command can therefore delete a model belonging to the wrong provider instead of reporting "not found". Parse the provider prefix once and skip rows from other providers before applying the shared equivalence relation.
Useful? React with 👍 / 👎.
…-jun#2596) slugEquals compares the raw and encoded spellings of ONE id, so a removal selector written in the native slash form matched only the slash row while the encoded form matched both. Catalog filtering and persisted sync had already agreed on the collision class through slugEquivalenceKey; this command disagreed with both on the same config, which is the inconsistency lidge-jun#2491 reports. Removal now resolves through resolveSlugSelection, so all three surfaces see the same collision. Behaviour on an ambiguous selector is unchanged and deliberately so: it still refuses, which is the right default for a destructive command - the widening makes it refuse in a case where it previously deleted a row silently. Driven red: with the narrow exact-only relation, 3 of the 21 cases fail.
…-jun#2596) slugEquals compares the raw and encoded spellings of ONE id, so a removal selector written in the native slash form matched only the slash row while the encoded form matched both. Catalog filtering and persisted sync had already agreed on the collision class through slugEquivalenceKey; this command disagreed with both on the same config, which is the inconsistency lidge-jun#2491 reports. Removal now resolves through resolveSlugSelection, so all three surfaces see the same collision. Behaviour on an ambiguous selector is unchanged and deliberately so: it still refuses, which is the right default for a destructive command - the widening makes it refuse in a case where it previously deleted a row silently. Driven red: with the narrow exact-only relation, 3 of the 21 cases fail.
Summary
Completes #2491, together with #2594.
slugEqualscompares the raw and encoded spellings of one id, so a removal selectorwritten in the native slash form matched only the slash row while the encoded form matched
both. Catalog filtering and persisted sync had already agreed on the collision class through
slugEquivalenceKey;ocx models removedisagreed with both on the same config. That isthe inconsistency the issue reports.
Demonstrated directly against a config publishing both spellings:
Removal now goes through
resolveSlugSelection(added in #2594), so all three surfaces seethe same collision.
Ambiguous selectors still refuse, deliberately. That behaviour is unchanged — what
changes is that the command now refuses in a case where it previously deleted a row
silently. For a destructive command, refusing on an ambiguous selector is the right default,
so the relation was widened without making removal tolerant.
Not changed
decodeRoutedModelIdOrThrowkeeps its own encode-collision check. It answers a differentquestion — may this request be routed at all — and it already fails closed on ambiguity, so
folding it into the selection resolver would trade a hard refusal for a softer match on the
request path. Recorded rather than silently left out.
Verification
Driven red: replacing the shared resolver with the narrow exact-only relation fails 3 of the
21 cases.
New cases pin both directions: a native-slash selector now sees the same collision the
encoded one does, and an unambiguous slash selector still removes its row — widening the
relation must not make ordinary removal ambiguous.
Checklist
devdevheadSummary by CodeRabbit
Bug Fixes
Tests