Skip to content

[upstream #4662] Fix #4651 default asset languagecode - #36

Open
ayim wants to merge 15 commits into
masterfrom
mirror/upstream-4662
Open

[upstream #4662] Fix #4651 default asset languagecode#36
ayim wants to merge 15 commits into
masterfrom
mirror/upstream-4662

Conversation

@ayim

@ayim ayim commented Jul 28, 2026

Copy link
Copy Markdown
Owner

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 on asset_translation.languageCode when called without an explicit RequestContext. The root cause: the fallback used RequestContext.empty(), which constructs new Channel() with no defaultLanguageCode, leaving ctx.languageCode as undefined when createAssetInternal builds the default translation.

This PR introduces a new RequestContextService.createDefaultContext() method that builds a RequestContext based on the default Channel, guaranteeing a valid languageCode (falling back to ConfigService.defaultLanguageCode if the channel has none) and currencyCode. 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 — add createDefaultContext() (admin API type, authorized, derived from the default channel).
  • packages/core/src/service/services/asset.service.ts — inject RequestContextService and use createDefaultContext() as the fallback in createFromFileStream.
  • packages/core/e2e/asset-create-from-file-stream.e2e-spec.ts — new e2e test reproducing the original issue by calling
    createFromFileStream without a RequestContext.
  • 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 no
RequestContext is passed (which threw a DB constraint error before).

Screenshots

N/A — backend-only change.

Checklist

📌 Always:

  • I have set a clear title
  • My PR is small and contains a single feature
  • I have checked my own PR

👍 Most of the time:

  • I have added or updated test cases
  • I have updated the README if needed

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.

AssetService.createFromFileStream() fails without RequestContext because of missing languageCode

3 participants