Skip to content

OpenConceptLab/ocl_online#730 | Search facets name only the sources and owners the requester can view; a REST edit that sends no access saves every column but the access - #1050

Open
paynejd wants to merge 4 commits into
masterfrom
fix/730-search-facets
Open

paynejd wants to merge 4 commits into
masterfrom
fix/730-search-facets

Conversation

@paynejd

@paynejd paynejd commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

For OpenConceptLab/ocl_online#730 (items 1 and 2, follow-up to #1048). References it without closing it. These are the fixes for the third Codex pass on #1048's last commit (45fba55), which came in after #1048 was approved and merged; that pass and its replies are on #1048.

Search facets name only repositories the requester can view (F3.2)

#1048 loads search hits through the database's access check, so a stale index document (a source made private before it, or its concepts and mappings, were reindexed) is no hit. Facets still came from the index, so they could still name that source and its owner.

Now, where the search filters by access (get_search_visibility_criteria(), the condition the search itself uses, now factored out), keep_repo_facets_viewable() (core/common/views.py, next to #1044's collection check, on cached facets too) checks every facet that names repositories:

  • source and owner (concept, mapping, source, collection and repo searches): a name stays only if it names a repository the requester can view, any version.
  • a mapping's fromConceptSource, toConceptSource, fromConceptOwner, toConceptOwner and a concept's targetRepo: a name is left out if the repositories it names exist and the requester can view none of them, so a target outside OCL keeps its name.

One query per facet and model, prefiltered to the bucket names. Where the index keeps the names' case (a concept search's facets, the target facets) they're matched as they are, which an index can serve; the lowercased facets match any case, so names that differ only in case are one bucket there. Counts stay the index's, as num_found does. A hit kept as its creator's can have its names missing, never a wrong one. Staff see the facets as they are.

A REST edit that sends no access doesn't write the access column (F3.3)

#1048 kept such an edit from undoing a concurrent access change by reading the row under a lock, in a transaction. Inside a transaction a failed search-index enqueue is only logged, where REST writes under autocommit report it to the request (kept that way in #1009's review).

Now persist_changes(..., keep_access=True) takes no lock: it saves every column but public_access (update_fields), so a concurrent write's access stays whenever it commits, and the edit runs under autocommit as before #1048; it then reads the row's access back for the response. A row stored with a blank access is the exception: it's saved as #1048 saved it, under the lock in one transaction, storing None and passing it on to a source's concepts and mappings. FHIR updates keep keep_private=True and its lock.

Not changed: source and collection CSV exports (F3.1)

The pass found that a source or collection CSV search whose only hit is dropped falls back to the plain list. That path can't be reached on master: a source or collection CSV export fails before it writes anything, with or without hits. That's tracked separately in OpenConceptLab/ocl_online#759.

Tests

  • tests_stale_search_access.py (es): rows made private without a reindex are no source, owner or mapping target facet name for the public or an outsider in the concept, mapping, source, collection and repo searches (members and staff still see them); a public case twin doesn't keep a concept facet's private name; a stale name no row has is no source or owner name; a target URL facet hides a private repository's URL and keeps one outside OCL.
  • test_make_private.py: a name-only PATCH's save leaves public_access out and locks nothing, a PATCH that sends access writes it; an access changed between the edit's read and its save stays, and the response has it; a blank-access row is read for update and stored as None; RestEditIndexEnqueueTest: a failed index enqueue reaches a name-only PATCH of a source and a collection.
  • Each new test fails on the code before it (master, or the commit before its fix) and passes here. Full suite at c6a3d34, as CI runs it: 3,673 tests (TEST_ES=off, parallel) and 719 (es), OK. pylint -j0 core/ (4.0.9): clean.

Reviewer: @snyaggarwal.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AaZ4qW1SrjGg8mwU3zehyF

paynejd and others added 2 commits November 24, 2026 02:03
…nd owners the requester can view

Where a search filters by access, each source or owner facet name stays only if a repository the requester can view has it, so a stale index document doesn't name a source made private, or its owner. Counts stay the index's. The search's access filter moves into get_search_visibility_criteria(), which the facets read too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qW1SrjGg8mwU3zehyF
…s every column but the access, with no lock

So a concurrent write's access stays whenever it commits, and the edit runs under autocommit, where a failed search-index enqueue reaches the request. A blank access is still stored as None, while it's still blank.

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

paynejd commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Simplification review (Claude subagent, commit d009179)

Verdict: 2 items, both low confidence; neither applied, so no new commits.

  • S1 shrink core/common/views.py:855: lower each facet name once by building a {lowered name: bucket} dict. Not applied: two buckets can differ only by case (the concept facets keep case, and owners whose names differ only in case exist), and the dict would drop one of them.
  • S2 shrink core/common/models.py:1456: the update_fields list and the blank-access update write an access rule in two places; go back to setting the access with no lock. Not applied: without the lock, writing the column can undo a concurrent access change, which is item 1; leaving the column out is what lets the edit run without one, and the conditional update keeps the blank-is-private rule from OpenConceptLab/ocl_online#365 | The write checkpoint asks make_private when a repository row is saved as private #1009.

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

Review: two issues with the no-lock path for blank-access rows, plus four nits, inline.

Comment thread core/common/models.py Outdated
field.name for field in cls._meta.concrete_fields
if not field.primary_key and field.name != 'public_access']
obj.save(**kwargs)
if keep_access and original_repo.public_access == '': # stored as None, unless a write changed it

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.

Race on a blank-access row can leave a public source with private concepts and mappings. Without the lock, a blank row reads '', obj.public_access becomes None, and _should_update_public_access is True, so the post_save signal sets every concept and mapping to None. If a concurrent write sets the row to View between the read and the save, this conditional update correctly skips, but the children were already set to None from the stale value.

Scenario: source stored with ''; a name-only PATCH reads it; a make-public commits View; the PATCH saves without the column and its signal makes all children private; this update matches nothing.

Suggestion: for keep_access, do the blank-to-None update first as the conditional update and propagate to children only if it changed a row (or keep the lock just for the blank case).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed, thanks. Fixed in 01259ee the second way you suggest: a row stored with a blank access is saved as #1048 saved it, under the row lock in one transaction, so its None and the cascade to concepts and mappings either both happen or wait for the concurrent write. Every other edit that sends no access stays lock-free. The blank-access test now asserts the FOR NO KEY UPDATE read (fails on d009179).

Comment thread core/common/models.py
kwargs['update_fields'] = [
field.name for field in cls._meta.concrete_fields
if not field.primary_key and field.name != 'public_access']
obj.save(**kwargs)

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.

This fix-up is skipped when obj.save() raises after writing. Under autocommit the index enqueue runs inside save() through on_commit, and RestEditIndexEnqueueTest shows its error propagates out of save(). By then the UPDATE and the signal (children set to None) have run, but the next line never does, so the row keeps '' while its children are None. In #1048 this was one atomic save.

Suggestion: run the conditional filter(public_access='').update(...) before obj.save(), or in a finally.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Right. The separate fix-up is gone in 01259ee: the blank case is one locked transaction again, so the row, its None and the children's update commit together or not at all. (Only that rare case runs in a transaction, where a failed index enqueue is logged; all other edits that send no access run under autocommit and report it.)

Comment thread core/common/models.py
# no key update, so a concurrent child write's foreign-key check on the row isn't blocked
original_repo = (stored_rows.select_for_update(no_key=True) if lock else stored_rows).first()
original_repo = (stored_rows.select_for_update(no_key=True) if keep_private else stored_rows).first()
if keep_access or (keep_private and not original_repo.public_can_view):

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.

Nit: with keep_access this value now comes from an unlocked read and the column isn't saved, so if a concurrent write changes the access in between, the PATCH response (and anything later in the request that reads obj.public_can_view) reports the old access. Maybe obj.refresh_from_db(fields=['public_access']) after the save when keep_access is set.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in 01259ee: after the lock-free save, obj.refresh_from_db(fields=['public_access']), so the response has the access the row has after the save. New test test_a_rest_edit_that_sends_no_access_keeps_an_access_changed_between_its_read_and_its_save changes the access between the edit's read and its save and checks both the row and the response (fails on d009179).

Comment thread core/common/views.py Outdated
repo_models = [Collection] if self.document_model == CollectionDocument else (
[Source, Collection] if self.is_repo_document_model() else [Source])
for facet in named:
names = {str(name).lower() for name, _, _ in facets[facet]}

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.

Nit: owner names are matched ignoring case, but get_scope_owner_criteria treats owners that differ only in case as other owners. So a private org ACME with stale docs keeps its owner facet bucket (with its private hit counts) when a user acme has a viewable repo. The source facet is matched across all owners in the same way. Match exactly where the facet isn't lowercased, or note in the docstring that this is accepted.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 01259ee where the index keeps the names' case: a concept search's source and owner facets (and the mapping from/to facets and targetRepo, now checked too) are matched exactly, so a twin that differs only in case doesn't keep a private name (new test). The mapping, source, collection and repo source/owner facets are lowercased in the index, so names that differ only in case are one bucket there; it stays if any of them is viewable. The docstring says so.

Comment thread core/common/views.py Outdated
for facet in named:
names = {str(name).lower() for name, _, _ in facets[facet]}
name_field = Lower('mnemonic') if facet == 'source' else Lower(
Coalesce('organization__mnemonic', 'user__username'))

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.

Nit (performance): this adds one or two DB queries per facet to every non-staff search facet request, cached facets included. Each applies get_viewable_versions_criteria (with its Exists) to all HEAD repos and filters on Lower(...)/Lower(Coalesce(...)) across joins, which a plain index can't serve. get_search_visibility_criteria() is also computed a second time. Worth checking the plan on production-size data, or prefiltering to the bucket names.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Reduced in 01259ee: the facets reuse the search's own search_checks_access when the facets search was built (only a cached facets answer works out the filter again), and the exact-case facets (a concept search's, the most common) use mnemonic IN (...) / organization__mnemonic IN / username IN / uri IN, which an index can serve; the bucket names (at most FACET_SIZE) prefilter every query. The lowercased facets of mapping and repo searches still use lower(), which a plain index can't serve. I can't read production data from here, so an EXPLAIN of one source-facet query there would settle it; if it's slow, an expression index on lower(mnemonic) is the fix.

Comment thread core/common/views.py
from core.collections.models import Collection
from core.sources.models import Source
repo_models = [Collection] if self.document_model == CollectionDocument else (
[Source, Collection] if self.is_repo_document_model() else [Source])

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.

Nit: Python's str.lower() and Postgres lower() can differ for some non-ASCII characters (depending on the DB ctype), so a viewable name could fail to match and its bucket would drop for non-staff users.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Mnemonics and usernames are ASCII only (NAMESPACE_REGEX, [a-zA-Z0-9\-\.\_\@]), where Python's and Postgres's lower() agree; and since 01259ee the concept facets don't lowercase at all. A legacy non-ASCII name could only go missing from a facet, never be wrongly kept.

… requester can view none of; a blank-access edit saves under the lock

- The mapping facets that name the sources and owners of the concepts mapped from and to, and a concept's targetRepo, are checked too. A name is left out if the repositories it names exist and the requester can view none of them, so a target outside OCL keeps its name. Any version counts, not only HEAD.
- A concept search's source and owner facets keep the names' case, so they're matched as they are, by index; the lowercased facets match any case.
- The facets reuse the search's own access-filter answer when it ran.
- A REST edit that sends no access to a row stored with a blank access saves under the row lock again, in one transaction, so it stores None and passes it on to a source's concepts and mappings without undoing a concurrent change. Other such edits answer with the access the row has after the save.

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

paynejd commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Codex check of commits 93d5690..d009179 (codex-cli 0.169.0)

Verdict: 3 findings, all P2. Prior: F3.2 unresolved (FC.1), F3.3 regressed (FC.2).

  • FC.1 P2 core/common/views.py:853: a concept search's facets keep the names' case, but the check lowercased them, so a public owner or source whose name differs only in case kept a private one's exact name.
  • FC.2 P2 core/common/models.py:1460: on a row stored with a blank access, the lock-free save's signal passes None to the source's concepts and mappings even when a concurrent publish won.
  • FC.3 P2 core/common/views.py:858: requiring a viewable HEAD dropped owner names of viewable rows that aren't HEAD.

Replies (01259ee):

check-1050.json
{
    "reviewer": "codex-cli 0.169.0",
    "perspective": "defects",
    "mode": "verify",
    "commit": "d009179b",
    "verdict": "findings",
    "prior": [
        {
            "id": "F3.2",
            "status": "unresolved"
        },
        {
            "id": "F3.3",
            "status": "regressed"
        }
    ],
    "findings": [
        {
            "id": "FC.1",
            "severity": "P2",
            "tag": null,
            "file": "core/common/views.py",
            "line": 853,
            "claim": "The concept owner facet can still expose the exact name of a private owner.",
            "scenario": "Two distinct organizations are named `ExampleOrg` and `exampleorg`. A concept under `ExampleOrg` still has a public index document after its source becomes private. An anonymous search drops the hit, but the public source under `exampleorg` keeps the exact `ExampleOrg` bucket because the database check lowercases both names.",
            "action": "Match exact-case concept facet labels as stored. Use lowercase comparisons for facets backed by lowercase-normalized index fields, and test the original bucket labels.",
            "lines_delta": null,
            "confidence": "high"
        },
        {
            "id": "FC.2",
            "severity": "P2",
            "tag": null,
            "file": "core/common/models.py",
            "line": 1460,
            "claim": "An edit that omits access can overwrite the access a concurrent publish gave the source's concepts and mappings.",
            "scenario": "A metadata PATCH reads a source with legacy blank access and prepares to normalize it to `None`. Another request publishes the source and finishes updating its children before the PATCH saves. The PATCH's save signal sets the children back to `None`. Its conditional update then skips the source because it is already `View`, leaving the published source's children hidden by the database access check.",
            "action": "Run the legacy-blank child cascade only if the conditional normalization updates the source. Keep the normalization and cascade in the same transaction, and surface any index enqueue error after commit.",
            "lines_delta": null,
            "confidence": "high"
        },
        {
            "id": "FC.3",
            "severity": "P2",
            "tag": null,
            "file": "core/common/views.py",
            "line": 858,
            "claim": "An all-versions search can lose the owner facet for a public repository version it still returns.",
            "scenario": "An owner changes their only public source's writable `version` from `HEAD` to `v1`. After reindexing, an anonymous source search with `allVersions=true` still returns the public `v1` row. The same search now drops its owner bucket because the facet check requires a viewable HEAD.",
            "action": "For all-versions searches, allow viewable non-HEAD rows to supply owner facet names and apply the same version access check used for hits.",
            "lines_delta": null,
            "confidence": "high"
        }
    ]
}

@paynejd

paynejd commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Adversarial pass (Claude subagent, read-only, #1048 + #1050 at d009179)

It tried to make search return a hit or a facet name the requester can't view, and to make a REST edit undo a concurrent access change, as anonymous, an outsider, a former member, a creator and staff, across scopes, versions, the facet and list caches, Compress, CSV, the repo search, $match and GraphQL.

  • A1 P2, fixed in 01259ee: the mapping facets fromConceptSource, toConceptSource, fromConceptOwner, toConceptOwner and a concept's targetRepo named the same stale source and owner. They're checked now too; a name is left out only if the repositories it names exist and the requester can view none of them, so a target outside OCL keeps its name. The facet test covers the four mapping facets (fails on d009179), and test_a_url_facet_hides_a_private_repository_s_url_and_keeps_one_outside_ocl covers targetRepo's URLs. source_version (release names) and updatedBy (signed-in requesters only) are accepted.
  • A3 P3, fixed in 01259ee: the blank-access race (same as FC.2 and the review above).
  • A4 P3, fixed in part: the response now has the row's current access. The rest of A4, and A2 and A5, are pre-existing gaps on routes and paths this PR doesn't touch; I've passed them on to be tracked separately.

It found no way for a REST edit that sends no access to make a private row viewable, and nothing else beyond the accepted items.

…ly if it names a repository the requester can view

As it did before the target facets were checked: a stale document's source or owner that no row has any more (deleted or renamed) is no facet name. A target facet still keeps a name no repository has, such as a mapping's target outside OCL.

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

paynejd commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Codex check of commits d009179..01259ee (codex-cli 0.169.0)

Verdict: 4 findings: 2 P1, 2 P2. Prior: FC.1, FC.2, FC.3 resolved.

  • FC2.1 P1 core/common/views.py:879: targetRepo matches OCL paths, so a canonical URL of a private target stays a bucket.
  • FC2.2 P1 core/common/views.py:852: a search in the requester's own scope that applies no access filter leaves its mapping targets' facets unchecked.
  • FC2.3 P2 core/common/views.py:867: a stale source or owner name that no row has any more (deleted or renamed) came back, which d009179 left out.
  • FC2.4 P2 core/common/views.py:864: a private local source can hide an external target that shares its name.

Replies (c6a3d34):

  • FC2.1, accepted: not a stale-index case. The bucket comes from a concept the requester can view, whose own mappings show that URL; the check only hides what it can match to a repository the requester can view none of.
  • FC2.2, accepted: same: those buckets name what the search's own hits name, in a scope whose permission check lets the requester see them.
  • FC2.3, fixed: a source or owner name stays only if it names a repository the requester can view, as before; only the target facets keep a name no repository has. New test: test_a_stale_document_names_no_source_or_owner_that_no_row_has, which fails on 01259ee.
  • FC2.4, accepted: a name can go missing, never be wrongly kept; it needs an external target and a private local source with the same name.
check2-1050.json
{
    "reviewer": "codex-cli 0.169.0",
    "perspective": "defects",
    "mode": "verify",
    "commit": "01259ee2468f7dea7186aaa86ee594fb10762cf1",
    "verdict": "findings",
    "prior": [
        {
            "id": "FC.1",
            "status": "resolved"
        },
        {
            "id": "FC.2",
            "status": "resolved"
        },
        {
            "id": "FC.3",
            "status": "resolved"
        }
    ],
    "findings": [
        {
            "id": "FC.1",
            "severity": "P1",
            "tag": null,
            "file": "core/common/views.py",
            "line": 879,
            "claim": "`targetRepo` only checks stored repository paths, so canonical URLs for private sources remain visible.",
            "scenario": "A public concept has a mapping whose stored `to_source_url` is the canonical URL of a linked OCL source. When the target becomes private, the concept index still emits that canonical URL. The `uri__in` lookup finds no row for it, so an outsider still sees the `targetRepo` bucket. The new test calls the helper with `Source.uri`, which misses this path.",
            "action": "Apply the access check to canonical URLs that resolve to local sources. Add an endpoint test covering a private canonical target and an unresolved external URL.",
            "lines_delta": null,
            "confidence": "high"
        },
        {
            "id": "FC.2",
            "severity": "P1",
            "tag": null,
            "file": "core/common/views.py",
            "line": 852,
            "claim": "Owner-scoped mapping searches skip access checks on the repositories their mappings point to.",
            "scenario": "A member searches mappings in their own organization's source. A mapping points to another organization's source that has become private. When the requesting organization has no case twin, the mapping search builds no access filter and this guard skips facet filtering. The member still sees the private target's `toConceptSource` and `toConceptOwner` buckets.",
            "action": "Check facets that name mapping endpoints independently of whether the parent search applies an access filter. Cover an owner-scoped search with a target outside the requester's organization.",
            "lines_delta": null,
            "confidence": "high"
        },
        {
            "id": "FC.3",
            "severity": "P2",
            "tag": null,
            "file": "core/common/views.py",
            "line": 867,
            "claim": "Stale `source` and `owner` buckets reappear after their repository rows are removed.",
            "scenario": "A public concept document remains in Elasticsearch after its source is deleted. If no other repository matches the source or owner name, the database lookup returns neither name as hidden. The public facets still list those names even though the search returns no hit. The preceding commit dropped both buckets.",
            "action": "Keep `source` and `owner` buckets only when a viewable repository matches. Preserve unknown names on facets that can represent external targets.",
            "lines_delta": null,
            "confidence": "high"
        },
        {
            "id": "FC.4",
            "severity": "P2",
            "tag": null,
            "file": "core/common/views.py",
            "line": 864,
            "claim": "An unrelated private source can hide a valid external `toConceptSource` bucket.",
            "scenario": "A public mapping points to an unresolved external URL ending in `ICPC-2`. The mapping document uses that last segment as its target source name. If the only local source named `ICPC-2` is private and unrelated to the URL, the mnemonic lookup suppresses the external bucket that the preceding commit returned.",
            "action": "Use the contributing mappings' target identities to check access, preserving a bucket when an external target contributes to it.",
            "lines_delta": null,
            "confidence": "high"
        }
    ]
}

@paynejd
paynejd requested a review from snyaggarwal November 24, 2026 07:37

@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 c6a3d34. Thanks for working through my earlier comments: the blank-access case is one locked transaction again, the response reads the access back after the save, the concept and target facets match names exactly, and the facet queries are limited to the bucket names. An EXPLAIN of a lowercased source-facet query on production data is still worth doing; if it's slow, an expression index on lower(mnemonic) would fix it, as you said.

Your Codex and adversarial passes (FC2.1 to FC2.4, A1 to A5) are covered, so I have nothing to add there. Inline: three optional nits.

Comment thread core/common/views.py
# a concept search's source and owner facets keep the names' case, as the others' facets do but those
exact = facet not in ('source', 'owner') or self.is_concept_document()
key = str if exact else lambda name: str(name).lower()
shown, hidden = self.get_repo_names_by_access(

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.

Nit (optional): source names are matched by mnemonic across every owner, so a private source with stale documents keeps its bucket, with its counts, whenever any other owner has a viewable source of the same name. Copies of CIEL or ICD-10 nearly always have a public twin, so for those the check rarely hides anything. Buckets aren't owner-qualified, so it can't do much better here. A line in the docstring saying so would be enough.

Comment thread core/common/models.py
obj.custom_validation_schema = original_schema

if keep_access and not lock:
kwargs['update_fields'] = [

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.

Nit (optional): with public_access left out of update_fields, a row stored with the retired Edit now stays Edit after such an edit. BaseModel.save normalizes it to View only in memory, and refresh_from_db reads Edit back. On master every such edit wrote View. It's harmless, since both count as public, but the legacy value now lingers. Either include the column when the stored value is the retired Edit, or accept it.

Comment thread core/common/views.py
user = self.request.user
named = [facet for facet in self.repo_name_facets if facets.get(facet)]
if not named or get(user, 'is_staff') or not (
self.search_checks_access if search is not None else self.get_search_visibility_criteria() is not None):

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.

Nit (optional): the fresh path uses search_checks_access, which is also True for an org search in the requester's own scope (is_org_document()). The cached path recomputes get_search_visibility_criteria() is not None, which is None there. Org searches have none of these facets, so nothing shows today, but the rule lives in two places. One helper for both would keep them from drifting.

This branch has not been deployed

No deployments
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