Skip to content

Registry scoping updates - #274

Open
ndamania00 wants to merge 16 commits into
dynotx:mainfrom
ndamania00:registry-scoping-fixes
Open

ndamania00 wants to merge 16 commits into
dynotx:mainfrom
ndamania00:registry-scoping-fixes

Conversation

@ndamania00

@ndamania00 ndamania00 commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Some updates to the original PR #262 for registry scoping

  • Made properties in BenchlingService cached for better performance
  • Validates in BenchlingService.__init__ whether it has ambiguous registries
    • len(self._registries) > 1 and self.connection.registry_id is None
  • Added registry_scoped and organization_scoped to list_all_items_v3, the base helper method for querying the v3 api.
    • Moves filtering based on registry and organization (for result schemas) here
  • updated tests
  • simplifed dropdown util functions to use the v3 api instead of the v2 sdk

mghent and others added 2 commits October 22, 2026 08:06
Adds an optional registry_id to BenchlingConnection, resolved through
GET /api/v3/registry/{id}. When set, entity schemas and dropdowns are
filtered to that registry, and results schemas to its owning
organization.

On a tenant with several registries and no registry_id, lookups that
match objects in more than one registry raise AmbiguousRegistryError,
and creating a schema or dropdown fails during validation. registry_id
and organization_id raise a clear error in place of a bare assert.

Single-registry tenants without registry_id behave as before.

Closes dynotx#43

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…try_id, move validation to base helpers, clean and simplify implementation
@ndamania00

Copy link
Copy Markdown
Collaborator Author

Manual testing still to be done

@ndamania00 ndamania00 added semver:minor Added functionality in a backwards compatible manner (minor version bump) type:major-enhancement New major feature or change labels Nov 2, 2026
- list registries from /api/v3/registry/items, without the archived
  filter that endpoint rejects
- entity schema records carry an organization but no registry, so
  is_in_registry_scope falls back to the registry's organization
- check for ambiguous registries only when use_api is set
- check registry_id against the registry list on single-registry tenants
- tests use record shapes that match the v3 API, and check the registry
  list request
@mghent

mghent commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Thanks - I like this approach, it's cleaner.

I tested it against our tenant with six registries, and found a few things:

  • Listing registries failed. The registry list lives at /api/v3/registry/items, and it doesn't accept the archived filter.
  • Entity schemas were filtered out. Their records carry an organization but no registry, so the new scoping dropped all of them. Falling back to the organization fixes it.
  • Two edge cases. A database-only connection failed because the new check calls the API, and on a one-registry tenant a wrong registry_id went unnoticed.

I've opened a PR into your branch with fixes for all four (ndamania00#1), plus tests that use the record shapes the API actually returns. With it, diffs and a round trip are clean on two registries, and creating a dropdown and a schema lands them in the right registry.

One unrelated thing I noticed: rolling back a revision that created a schema and the dropdown it uses doesn't work. Liminal won't archive a dropdown that's still in use, but it checks the models in code rather than Benchling, so the dropdown always looks in use. Happy to open a separate issue for that.

@ndamania00

Copy link
Copy Markdown
Collaborator Author

Great, thanks! I created an issue here #275 to track the rollback you noticed as well

@ndamania00

Copy link
Copy Markdown
Collaborator Author

@mghent I merged in your changes and made one tweak. I reverted the logic in is_in_registry_scope and just set organization_scoped=True in liminal/entity_schemas/api.py since it provides organization in the payload but not registry.

I'm still waiting for Benchling support to update my tenant to have multiple registries so I will merge this in after this gets configured for me and I can do some last testing myself!

@mghent

mghent commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Sounds good, thanks! I reran our tests on your latest commit, and diffs and a round trip match our current version across three registries. Let me know if you'd like anything else tested, but I think it's ready to merge.

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

semver:minor Added functionality in a backwards compatible manner (minor version bump) type:major-enhancement New major feature or change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants