fix: v2/v3 data access runtime switch with instanceof fixes#1831
Merged
fix: v2/v3 data access runtime switch with instanceof fixes#1831
Conversation
Re-apply the v2/v3 data access runtime switch (reverted in #1828) with fixes for the cross-package instanceof failures that caused the production outage. Changes: - Upgrade spacecat-shared-data-access to v3, keep v2 as npm alias - Add runtime switch middleware (DATA_SERVICE_PROVIDER env var) - Replace instanceof ValidationError with error.name check - Replace instanceof Site/Organization/Project with entityName check - Update all affected tests to use entityName mock pattern Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
This PR will trigger a patch release when merged. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
solaris007
reviewed
Feb 19, 2026
Member
solaris007
left a comment
There was a problem hiding this comment.
@ekremney - the .name may be similarly affected as instanceof.
Consider these PRs:
…e checks Replace instance property checks (entity.entityName === 'site') with static constant checks (entity.constructor.ENTITY_NAME === 'Site') for more robust cross-package entity type identification. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
solaris007
approved these changes
Feb 19, 2026
Member
|
🎉 This PR is included in version 1.320.4 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
Summary
instanceoffailures that caused the production outageinstanceof ValidationErrorwitherror.name === 'ValidationError'checks in controllers (fixes, opportunities, suggestions)instanceof Site/Organization/Projectwithentity.entityNamechecks in access-control-utilentityNamemock pattern instead ofObject.setPrototypeOfRoot Cause
When v3 is installed as the main package and v2 as an npm alias,
instanceofchecks against v3 classes fail for v2-created instances (different constructors from different packages). The fix uses duck-typing viaentityNameproperty anderror.namestring checks, both of which are stable across v2/v3.Test plan
DATA_SERVICE_PROVIDER=postgresswitches to v3🤖 Generated with Claude Code