Repository navigation
OpenConceptLab/ocl_online#737 | Invalid reference IDs answer 404, fuzzy search answers on mapping and collection lists, HEAD answers as GET on details, default expansions stay - #1047
Open
paynejd wants to merge 4 commits into
Conversation
…fuzzy search answers on mapping and collection lists, HEAD answers as GET on details, and default expansions stay - A reference's detail URL answers 404 for an ID that isn't ASCII digits, or that no reference can have, as its concept and mapping lists already do. Both views share one helper. - A fuzzy search on a mapping list, or on a collection's concept list, keeps to the URL's repository as plain search does. Only the source concept list sets fuzzy-search targets, and the other lists failed without them. - HEAD on a concept, mapping, source version or collection version detail, and on a collection version's expansions, takes the view permission GET takes, not the edit permission. - DELETE on an expansion's resolved-repo-updates answers 400 for the version's default expansion, as the expansion's own DELETE does. Both share one destroy; each keeps its own delete for any other expansion. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWLYoaHjge22WUiaxG
Member
Author
Codex review, pass 1 (codex-cli 0.169.0, commit a62af97)Verdict: findings: 1 P1, 1 P2.
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "full",
"commit": "a62af979",
"verdict": "findings",
"prior": [],
"findings": [
{
"id": "F1.1",
"severity": "P1",
"tag": null,
"file": "core/common/views.py",
"line": 68,
"claim": "Fuzzy searches on the unversioned collection concept and mapping lists can return members of non-default expansions.",
"scenario": "Give a collection's HEAD a default expansion and a second expansion with a different matching concept. A fuzzy search on the collection's `/concepts/` route returns that second concept because the Elasticsearch scope filters by collection and HEAD but omits the default expansion URI. The explicit `/HEAD/concepts/` route applies that URI filter.",
"action": "Scope fuzzy hits and search stats to the default expansion of the collection version the view resolved. Add a regression test with matching concepts in two expansions and verify both URL forms return only the default expansion's members.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F1.2",
"severity": "P2",
"tag": null,
"file": "core/common/views.py",
"line": 1145,
"claim": "A malformed score threshold still produces HTTP 500 on fuzzy mapping searches.",
"scenario": "A request to `/mappings/?fuzzy=true&q=heart&min_score=high` reaches `float(min_score)` in the newly enabled fuzzy path. The uncaught `ValueError` produces HTTP 500.",
"action": "Validate `min_score` before building the Elasticsearch query and return HTTP 400 for invalid values. Add a mapping-list regression test.",
"lines_delta": null,
"confidence": "high"
}
]
} |
… a finite number answers 400 The fuzzy search path read min_score with float(), so a value such as `high` answered 500 on every list that runs a fuzzy search. A value that isn't a finite number now answers 400, in the shape the pagination parameters use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWLYoaHjge22WUiaxG
Member
Author
Responses to Codex pass 1
|
…rs an empty list A query that is empty once quotes and spaces are stripped (`q=""`) builds no search, and search stats then failed on it with a 500, fuzzy or not. Such a search now answers [], as a search with no hits does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWLYoaHjge22WUiaxG
Member
Author
Codex review, pass 2 (codex-cli 0.169.0, commit 54d8c00)Verdict: findings: 1 new P2. Earlier: F1.1 unresolved (left out of scope, see pass 1 responses), F1.2 resolved.
Responses:
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "verify",
"commit": "54d8c00b",
"verdict": "findings",
"prior": [
{
"id": "F1.1",
"status": "unresolved"
},
{
"id": "F1.2",
"status": "resolved"
}
],
"findings": [
{
"id": "F2.1",
"severity": "P2",
"tag": null,
"file": "core/common/views.py",
"line": 1170,
"claim": "Stats-only fuzzy searches still return HTTP 500 when the query becomes empty after normalization.",
"scenario": "`GET /mappings/?fuzzy=true&searchStatsOnly=true&q=%22%22` enters the stats branch because the raw query contains two quote characters. Search removes the quotes and returns no Elasticsearch query, so aggregation calls `.extra()` on `None`. The collection concept list has the same failure.",
"action": "Return HTTP 400 when a stats-only request has an empty normalized query, and add a regression test for both lists.",
"lines_delta": null,
"confidence": "high"
}
]
} |
…ere a search runs; elsewhere the list answers as without it The stats-only shortcut ran before a view's own access check, so on a list that keeps that check in get_queryset (a collection version's expansions) a GET answered 200 where HEAD answered 403, and with a real query it failed there with a 500. It now runs only on a searchable list with a search string left after quotes and spaces are stripped. Any other request answers as the list does without searchStatsOnly, access check included. This replaces the empty-stats answer from the previous commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWLYoaHjge22WUiaxG
Member
Author
Codex review, pass 3 (codex-cli 0.169.0, commit 39b8341)Verdict: findings: 2 new P2. Earlier: F1.1 unresolved (out of scope, see pass 1 responses), F1.2 and F2.1 resolved.
Responses:
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "verify",
"commit": "39b8341f",
"verdict": "findings",
"prior": [
{
"id": "F1.1",
"status": "unresolved"
},
{
"id": "F1.2",
"status": "resolved"
},
{
"id": "F2.1",
"status": "resolved"
}
],
"findings": [
{
"id": "F3.1",
"severity": "P2",
"tag": null,
"file": "core/collections/views.py",
"line": 961,
"claim": "A private collection version's expansions list can answer 200 to GET while refusing HEAD.",
"scenario": "An outsider requests the expansions list with searchStatsOnly=true and a whitespace-only q. The GET stats branch now returns 200 with [] before get_queryset checks the version's permissions. HEAD reaches that check and returns 403.",
"action": "Check the version's read permission before the list mixin can return early. Add this request to the GET and HEAD parity test.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F3.2",
"severity": "P2",
"tag": null,
"file": "core/common/views.py",
"line": 1353,
"claim": "A stats-only fuzzy mapping search can still turn invalid search input into HTTP 500.",
"scenario": "A /mappings/ request with fuzzy=true, a nonempty q, and searchStatsOnly=true sends an oversized mapType wildcard filter. Elasticsearch rejects the generated regular expression, and the aggregation path lets the error escape. The hits path already translates that error to HTTP 400. [Elasticsearch regexp query limits](https://www.elastic.co/guide/en/elasticsearch/reference/8.15/query-dsl-regexp-query.html)",
"action": "Apply the hits path's request-error translation to aggregation execution and assert HTTP 400 in a stats-only mapping regression test.",
"lines_delta": null,
"confidence": "high"
}
]
} |
Member
Author
Simplification review (Claude Sonnet 5.5 subagent, commit a8ded90)Four suggestions; none applied.
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of OpenConceptLab/ocl_online#737. That ticket keeps its other items, so this PR doesn't close it.
What changes
Reference detail, invalid ID → 404.
CollectionReferenceViewpassed the URL's reference ID straight tofilter(id=…), so a GET, HEAD or DELETE with a non-numeric ID (versioned route), or one too long for an integer, answered 500. It now parses the ID as the reference's concept and mapping lists already do (ASCII digits only, else 404), through one helper both views share.Fuzzy search on mapping lists and a collection's concept list → 200.
BaseAPIViewreads_source_versionsand_extra_filtersfor a fuzzy search and for search stats, but only the source concept list sets them, so?fuzzy=trueon/mappings/, a source's mappings or a collection's concepts or mappings answered 500. Both now default toNone, so those searches keep to the URL's repository through__apply_scope_filters, as plain search does.HEAD on a detail answers as GET. Concept and mapping details, source and collection version details, and a collection version's expansions list gave the view permission to GET only, so HEAD asked for edit access (403 for an outsider on a public source). HEAD now takes the view permission too. Where GET is refused (a private source or collection), HEAD is refused the same way.
The default expansion can't be deleted through
resolved-repo-updates/. DELETE there fell through to the generic soft delete with no default-expansion check. The expansion base view now has onedestroythat refuses the default expansion with the expansion DELETE's 400 ({'errors': ['Cannot delete default expansion']}). Each view keeps its own delete for any other expansion: a delete on the expansion, a soft delete onresolved-repo-updates/, as before.Search parameters on the newly reachable fuzzy path (from the review passes). A fuzzy search's
min_scorethat isn't a finite number answers 400, not 500.searchStatsOnlyanswers stats only on a searchable list with a search string left after quotes and spaces are stripped. Any other request answers as the list does without it, access check included. Before,q=""failed with a 500, and on a list that checks access inget_querysetthe shortcut skipped that check.Tests
Each new test fails on master:
CollectionReferenceAccessTest.test_reference_with_an_invalid_id_answers_404:abc, 30 and 5,000 digits,+id,0_idand full-width digits, on both routes, for GET, HEAD and DELETE.DetailHeadAccessTest: GET and HEAD give the same status for anonymous, outsider and member, public and private, on the five views. The private case already passes on master; it pins that HEAD stays refused.FuzzySearchListsTest(es): fuzzy search on the global, source and collection mapping lists, and on a collection's concept list with and withoutincludeSearchStats, answers 200 and returns only the list's own members.FuzzySearchListsTestalso coversmin_score(high,nan,inf→ 400) and a stats-only search for nothing, which answers as the list.CollectionVersionExpansionResolvedRepoUpdatesViewTest: DELETE of the default expansion answers 400 and leaves it in place. A non-default one still answers 204.For the reviewer
DELETE on
resolved-repo-updates/looks accidental: the class inheritsDestroyAPIView, and the endpoint is a GET diff. If you'd rather it answer 405, that's a one-line change. This PR keeps it and adds the guard. Note that the soft delete it does for a non-default expansion changes nothing visible: nothing filters expansions onis_active, so the expansion stays listed and readable after the 204. That was already true on master.Left open from the review passes, both already true on master: an unversioned collection search, plain or fuzzy, isn't limited to the default expansion (another item on the tracking ticket); and a stats-only search that Elasticsearch rejects answers 500, because the aggregation path doesn't translate search errors to 400 as the hits path does.
🤖 Generated with Claude Code
https://claude.ai/code/session_01AaZ4qWLYoaHjge22WUiaxG