Skip to content

Inherit Tenanted::GlobalId::Locator from UnscopedLocator - #332

Merged
flavorjones merged 2 commits into
mainfrom
fix-global-id-on-edge
Aug 4, 2026
Merged

Inherit Tenanted::GlobalId::Locator from UnscopedLocator#332
flavorjones merged 2 commits into
mainfrom
fix-global-id-on-edge

Conversation

@flavorjones

Copy link
Copy Markdown
Member

Tenanted::GlobalId::Locator subclassed nothing, so it inherited none of GlobalID's locator behavior. It did not implement #model_class, which GlobalID 1.4.0 deprecated. It did not implement #locate_many, which GlobalID::Locator.fetch requires, so Active Job on Rails edge could not deserialize GlobalID arguments. It also applied a model's default_scope to GlobalID lookups, unlike Rails, whose default locator resolves GlobalIDs unscoped.

Tenanted::GlobalId::Locator will inherit from GlobalID::Locator::UnscopedLocator, the locator Rails installs by default, and will keep only the tenant safety check. #locate_many will enforce the same tenant checks as #locate.

`Tenanted::GlobalId::Locator` subclassed nothing, so it inherited none of
GlobalID's locator behavior. It did not implement `#model_class`, which
GlobalID 1.4.0 deprecated. It did not implement `#locate_many`, which
`GlobalID::Locator.fetch` requires, so Active Job on Rails edge could not
deserialize GlobalID arguments. It also applied a model's `default_scope`
to GlobalID lookups, unlike Rails, whose default locator resolves
GlobalIDs unscoped.

`Tenanted::GlobalId::Locator` will inherit from
`GlobalID::Locator::UnscopedLocator`, the locator Rails installs by
default, and will keep only the tenant safety check. `#locate_many` will
enforce the same tenant checks as `#locate`.
Copilot AI balanced review requested due to automatic review settings August 4, 2026 17:03
@flavorjones
flavorjones enabled auto-merge August 4, 2026 17:05
@flavorjones
flavorjones merged commit a5cbde0 into main Aug 4, 2026
12 checks passed
@flavorjones
flavorjones deleted the fix-global-id-on-edge branch August 4, 2026 17:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates the tenant-aware GlobalID locator to inherit standard unscoped lookup behavior while preserving tenant safety.

Changes:

  • Adds unscoped single and batch GlobalID lookup support.
  • Expands unit and Active Job integration coverage.
  • Updates Rails/GlobalID dependencies and changelog.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
lib/active_record/tenanted/global_id.rb Inherits unscoped locator behavior and validates batch tenants.
test/unit/global_id_test.rb Tests lookup, batching, tenant errors, and default scopes.
test/integration/test/active_job_test.rb Verifies wrapped tenant errors during deserialization.
Gemfile.lock Updates Rails, GlobalID, and resolved dependencies.
CHANGELOG.md Documents the corrected locator behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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