[upstream #4662] Fix #4651 default asset languagecode - #36
Open
ayim wants to merge 15 commits into
Open
Conversation
…fault RequestContext (vendurehq#4651)
…o asset.e2e-spec.ts
…iguration parameters
…code' into fix-vendurehq#4651-default-asset-languagecode
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.
Mirrored from vendurehq#4662 for the Overwatch review demo.
Original author: @kevmtt
Description
Fixes vendurehq#4651.
Since v3.6,
AssetService.createFromFileStream()fails with a NOT NULL constraint violation onasset_translation.languageCodewhen called without an explicitRequestContext. The root cause: the fallback usedRequestContext.empty(), which constructsnew Channel()with nodefaultLanguageCode, leavingctx.languageCodeasundefinedwhencreateAssetInternalbuilds the default translation.This PR introduces a new
RequestContextService.createDefaultContext()method that builds aRequestContextbased on the defaultChannel, guaranteeing a validlanguageCode(falling back toConfigService.defaultLanguageCodeif the channel has none) andcurrencyCode.AssetService.createFromFileStream()now uses this helper instead of RequestContext.empty()` when no ctx is supplied, restoring the pre-v3.6 behavior.Changes:
packages/core/src/service/helpers/request-context/request-context.service.ts— addcreateDefaultContext()(admin API type, authorized, derived from the default channel).packages/core/src/service/services/asset.service.ts— injectRequestContextServiceand usecreateDefaultContext()as the fallback increateFromFileStream.packages/core/e2e/asset-create-from-file-stream.e2e-spec.ts— new e2e test reproducing the original issue by callingcreateFromFileStreamwithout aRequestContext.docs/.../request-context-service.mdx— documents the new method.Breaking changes
None.
createDefaultContext()is additive, and the asset service change only affects the previously-broken path where noRequestContextis passed (which threw a DB constraint error before).Screenshots
N/A — backend-only change.
Checklist
📌 Always:
👍 Most of the time: