Skip to content

OpenConceptLab/ocl_online#736 | Unresolved-reference details list only repository versions the requester can view - #1028

Merged
snyaggarwal merged 8 commits into
masterfrom
ocl_online-736-unresolved-view-check
Nov 23, 2026
Merged

snyaggarwal merged 8 commits into
masterfrom
ocl_online-736-unresolved-view-check

Conversation

@paynejd

@paynejd paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member

Part of OpenConceptLab/ocl_online#736. Follows #1017 (OpenConceptLab/ocl_issues#3043), which is on master but not yet released.

What changes

The add-references response (PUT /…/collections/<c>/references/) names the repository versions a reference resolved to nothing in. That list now holds only versions the requester can view:

  • Resolved-to-nothing and excluded-by-parameters items: CollectionReference.get_evaluated_repo_version_urls takes the user and keeps only versions with has_view_access(user), the same check get_resolved_repo_versions_serialized already applies. With none left, it falls back to what the reference itself gives (its system and value sets), as it does today when no version resolves.
  • Pinned reference whose named version doesn't hold the resource version: the named version counts only if the requester can view it. Otherwise the item takes the "no version of {system} holds" path.

So a repository the requester can't view gets the same repo_versions and wording as a repository that doesn't exist. Members, owners and staff see what they see today.

Tests

  • CollectionReferencesViewTest: a private source in another org answers exactly like a missing source, for a versionless reference and for a pinned reference naming a version; an org member and a staff user still get the release's URL.
  • ExpansionTest: get_evaluated_repo_version_urls names the release to a member and falls back to the system for another user and for no user.
  • OpenConceptLab/ocl_issues#3043 | add-references response says when a reference resolved to nothing #1017's tests pass unchanged. Locally: core.collections, core.integration_tests.tests_collections and core.common (551 non-ES, 139 ES) and CI's pylint -j0 core/ (exit 0).

🤖 Generated with Claude Code

https://claude.ai/code/session_01AaZ4qTUrHhWdhdS68p12fx

…y repository versions the requester can view

The add-references response names the repository versions a reference
resolved to nothing in. It now names only versions the requester can
view. Otherwise it names what the reference itself gives (its system and
value sets), with the same wording as for a repository that doesn't
exist. Members, owners and staff see the versions as before, and the
same check is the one resolved_repo_versions already uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qTUrHhWdhdS68p12fx
@paynejd
paynejd requested a review from snyaggarwal November 23, 2026 04:10
…s that the requester can't view counts as missing in unresolved-reference details

A reference can name a version in its system URL. When the requester
can't view that version, the details no longer look up the versions the
expansion recorded for its repository; they name what the reference
gives, as for a version that doesn't exist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qTUrHhWdhdS68p12fx
@paynejd

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 1 (codex-cli 0.169.0, commit e696a0b)

Verdict: findings (2 × P1, 1 × P2). Two are in code this PR doesn't change; the third is fixed. The full findings are on the private tracker.

Next: pass 2 on da85344.

…e version a reference's system resolves to, however it is named

The previous check covered a version named in a form the reference
recognizes as versioned. A system URL without its trailing slash names
a version the same way for the resolver, so the check now applies to
whichever version the system resolves to.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qTUrHhWdhdS68p12fx
@paynejd

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 2 (codex-cli 0.169.0, commit da85344)

Verdict: findings (2 × P2). One is fixed; the other is in code this PR doesn't change. The full findings are on the private tracker.

Next: pass 3 on a032cc7.

…ly a version the reference's system names

A versionless reference again names the release its expansion recorded,
whatever newer release the requester can't view exists. The early check
applies only when the system names a version, with or without the URL's
trailing slash, as the resolver reads it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qTUrHhWdhdS68p12fx
@paynejd

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 3 (codex-cli 0.169.0, commit a032cc7)

Verdict: one finding (P2), fixed. Codex marks every earlier finding resolved; it now treats F1.1, F1.2 and F2.2 as outside this PR.

  • F3.1 (P2) a032cc7's check also covered versionless references. A versionless reference to a public source then named the source rather than the release its expansion recorded, whenever a newer release the requester can't view existed. Fixed in 8592e37: the check applies only when the reference's system names a version, with or without the trailing slash (reusing is_explicit_valueset's reading of a URL). The test adds that case and fails on a032cc7.

That's the third and last full pass; no P0 or P1 is open in this PR's code. Next: a simplification review, a Codex check of a032cc7..HEAD, and an adversarial pass.

…-version check into one line, drop a repeated assertion

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qTUrHhWdhdS68p12fx
@paynejd

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Simplification review (Claude subagent, commit 8592e37)

Verdict: four small cuts proposed; two applied in 4c89dce.

  • S1 (shrink, models.py) inline the names_version local. Not applied: the inlined condition runs past 120 characters, and the name helps reading.
  • S2 (shrink, views.py) fold the named-version reset into one line. Applied.
  • S3 (dup-test, tests.py) drop the user=None assertion, which repeats the non-member one. Applied.
  • S4 (dup-test, tests_collections.py) merge the member and staff tests. Not applied: each pins its own acceptance criterion, and the saving is boilerplate only.

Tests (core.collections, core.integration_tests.tests_collections, core.common: 551 non-ES + 174 ES) and pylint -j0 core/ pass on 4c89dce. Next: a Codex check of a032cc7..4c89dce.

simplify.json
{"reviewer":"claude subagent","perspective":"simplify","mode":"full","commit":"8592e373","verdict":"findings","prior":[],"findings":[{"id":"S1","severity":null,"tag":"shrink","file":"core/collections/models.py","line":1502,"claim":"The `names_version` local is used once, and the two-step `named_version` / `system_versions` conditionals can be one guard.","action":"named_version = self._get_expression_system_version(system_version_cache) if (self.names_repo_version or self.is_explicit_valueset(self.system or '')) else None, then keep the existing `system_versions = [] if named_version and not named_version.has_view_access(user) else ...`. Saves the separate `names_version` line. The access check itself stays.","scenario":null,"lines_delta":-1,"confidence":"low"},{"id":"S2","severity":null,"tag":"shrink","file":"core/collections/views.py","line":597,"claim":"The unviewable named version is reset to None with a separate 2-line `if`.","action":"Fold the check into the lookup: named_version = reference.resolve_expression_system_version if reference.names_repo_version else None; named_version = named_version if named_version and named_version.has_view_access(user) else None. This leaves the access check in place and drops one line.","scenario":null,"lines_delta":-1,"confidence":"low"},{"id":"S3","severity":null,"tag":"dup-test","file":"core/collections/tests/tests.py","line":4143,"claim":"In test_evaluated_repo_version_urls_name_only_versions_the_user_can_view, the `user=None` assertion (`[source.uri]`) repeats the non-member assertion on the line above it. Both reach the same `has_view_access` branch, and the view tests cover the requester path. Keep the member and non-member assertions, which pin the access change.","action":"Delete the `None` assertion line. The `None` argument is still exercised by the pre-existing missing-repository test.","scenario":null,"lines_delta":-1,"confidence":"low"},{"id":"S4","severity":null,"tag":"dup-test","file":"core/integration_tests/tests_collections.py","line":1180,"claim":"The member and staff view tests each build the same fixture and assert the same release URI, so they can be one parametrised test. Both are acceptance criteria and must still run. This only merges the boilerplate.","action":"Use a single test that loops over (member, staff) with `self.subTest`, or give `_private_source_with_empty_release` a `grant` parameter. Both cases stay covered.","scenario":null,"lines_delta":-6,"confidence":"low"}]}

…ersion in the system URL as the resolver does

The resolver drops a system URL's query string before it looks for a
version in the path, so the check does too, and it takes a version
after '|' as the resolver does. A query string can no longer hide a
version the system names, or make a versionless system look as if it
names one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qTUrHhWdhdS68p12fx
@paynejd

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Codex check of commits a032cc7..4c89dce (codex-cli 0.169.0)

Verdict: one finding (P2), fixed. Full findings are on the private tracker.

  • FC.1 (P2) the "does the system name a version" check read the raw system URL, but the resolver drops a query string first. So a query string could hide a named version, or make a versionless system look as if it named one. Fixed in 3bdb5d0: the check reads the system as the resolver does (split_canonical for '|', then the path without the query string). The unit test now runs every form with and without a query string, and fails on 4c89dce.

Tests (551 non-ES + 174 ES) and pylint -j0 core/ pass on 3bdb5d0. One non-ES run had an intermittent failure in ExportCollectionTaskTest.test_export_collection, which compared an exported source version against a collection version; it passed on rerun and doesn't touch this code. Next: a Codex check of 4c89dce..3bdb5d0, then an adversarial pass.

…ersion in a relative system URL by its position

The path check took an owner named like a repository type (an org
called "sources") for a repository, and read a versionless system as
naming a version. It now reads a relative URL's path by position
(/orgs|users/<owner>/<repo type>/<repo>/<version>/), with its query
string dropped as the resolver does, and a canonical URL's version
only after '|'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qTUrHhWdhdS68p12fx
@paynejd

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Codex check of commits 4c89dce..3bdb5d0 (codex-cli 0.169.0)

Verdict: one finding (P2), fixed.

  • FC.1 (P2) the path check, which uses drop_version's heuristic, took an owner named like a repository type (an org called sources) for a repository, so a versionless system read as naming a version. Fixed in d44a221: a relative system URL's path is now read by position with to_parent_kwargs_from_uri (query string dropped, as the resolver does), and a canonical URL names a version only after |. The unit test now runs under an org named sources and fails on 3bdb5d0.

Adversarial pass (fresh Claude subagent, commit 3bdb5d0)

Verdict: no finding in the response code this PR changes; one P3 note.

  • It traced the private and missing cases end to end: no version named; a version named by |, by path with or without the trailing slash, with a query string, or by the version field; private value sets; private versions under public repositories; the resource-version-not-held branch; owners, members and staff; the requester; the caches; the callers. The answer was the same for private and missing in every case, and nothing was hidden from those with access.
  • P3: the PR's own "names a version" reading differs from names_repo_version's, which reference evaluation uses. Not unified here: changing names_repo_version would change how references evaluate, which is outside this PR.

Tests (551 non-ES + 174 ES) and pylint -j0 core/ pass on d44a221. Next: a Codex check of 3bdb5d0..d44a221.

… version segment without parsing the rest of the path

A system URL with an empty segment, such as a doubled slash, made the
helper that names the repository type fail, so the response errored
after the reference was saved. The check now takes the fifth path
segment directly, and an empty one names no version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qTUrHhWdhdS68p12fx
@paynejd

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Codex check of commits 3bdb5d0..d44a221 (codex-cli 0.169.0)

Verdict: one finding (P2), a regression from d44a221, fixed.

  • FC.1 (P2) to_parent_kwargs_from_uri reads the repository-type segment's first character, so a system URL with an empty segment (/orgs/acme//catalog/) raised IndexError, and the response returned 500 after the reference was saved. Fixed in 2c275dd: the check takes the fifth path segment directly, and an empty segment names no version. The test adds that URL and errors on d44a221.

Tests (551 non-ES + 174 ES) and pylint -j0 core/ pass on 2c275dd. Next: a Codex check of d44a221..2c275dd.

findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "final",
  "commit": "d44a2213",
  "verdict": "findings",
  "prior": [
    {
      "id": "FC.1",
      "status": "resolved"
    }
  ],
  "findings": [
    {
      "id": "FC.1",
      "severity": "P2",
      "tag": null,
      "file": "core/collections/models.py",
      "line": 1506,
      "claim": "An empty repository-type segment now causes the add-references response to return HTTP 500 after saving the reference.",
      "scenario": "Add a concept reference with system `/orgs/acme//catalog/` to a collection with an expansion. The resolver treats the system as missing and saves an unresolved reference. While building the response, `to_parent_kwargs_from_uri` indexes the empty repository-type segment and raises `IndexError`. Before this commit, the response listed the supplied system URL in `repo_versions`.",
      "action": "Read the version segment from the normalized parent path without indexing the repository-type segment, and add a regression test for the unresolved response.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

@paynejd

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Codex check of commits d44a221..2c275dd (codex-cli 0.169.0)

Verdict: clean. The earlier FC.1 is resolved, and nothing new.

Review loop summary for 2c275dd: three full Codex passes, a simplification review (2 of 4 cuts applied), Codex checks of every later commit (the last one clean), and an adversarial access pass (clean in this PR's code). No P0 or P1 is open in this PR's code. Two findings (F1.2, F2.2) concern how references evaluate, outside this PR, and are recorded separately; F1.1 is #1024's.

@snyaggarwal snyaggarwal 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.

Approving at 2c275dd. A repository version the requester can't view now answers like one that doesn't exist, in both places the add-references response names versions:

  • get_evaluated_repo_version_urls keeps only versions with has_view_access(user). When the system names a version the requester can't view, it uses the system or value sets instead of the expansion's recorded version. Its one caller passes the request's user.
  • A pinned reference's named version counts only when the requester can view it, so the item otherwise takes the "no version of {system} holds" wording.

Reading the system as the resolver does (after |, the fifth path segment without the query string, and an empty segment naming none) covers each form your Codex checks found. Members, owners and staff are unchanged.

It merges cleanly with master now that #1009 is in. CI is green. I haven't run the tests.

Fine to leave F1.1 (#1024's), F1.2 and F2.2 out of scope, as they're in reference evaluation and on master already.

@snyaggarwal
snyaggarwal merged commit 2b12949 into master Nov 23, 2026
3 checks passed
@snyaggarwal
snyaggarwal deleted the ocl_online-736-unresolved-view-check branch November 23, 2026 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants