Skip to content

CEXT-6073: add required id field to ConfigOrigin#389

Closed
obarcelonap wants to merge 3 commits intomainfrom
CEXT-6073/add-id-to-config-origin
Closed

CEXT-6073: add required id field to ConfigOrigin#389
obarcelonap wants to merge 3 commits intomainfrom
CEXT-6073/add-id-to-config-origin

Conversation

@obarcelonap
Copy link
Copy Markdown
Member

Description

ConfigOrigin now carries a required id field alongside the existing code and level fields. This allows consumers to unambiguously identify which scope a configuration value is inherited from, using the scope's unique identifier rather than relying on code+level alone. Schema-default origins use the sentinel value "default" for this field.

Propagated through mergeScopes, mergeWithSchemaDefaults, and all internal merge helpers. The changeset is marked minorConfigOrigin only appears in read-only response types; no write API accepts it as input.

Related Issue

https://jira.corp.adobe.com/browse/CEXT-6073

Motivation and Context

The UI needs to confidently determine whether a config value is inherited or locally set. code + level alone are not sufficient since multiple scopes can share the same level. The scope id is the canonical unique identifier.

How Has This Been Tested?

  • 134 unit and integration tests pass (npx vitest run)
  • TypeScript check passes (npx tsc --noEmit)
  • New test/unit/config-utils.test.ts covers mergeScopes id propagation: new entries, overridden entries, preserved inherited origins, and fallback for origin-less entries

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have read the DEVELOPMENT document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 15, 2026

🦋 Changeset detected

Latest commit: efdfe58

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@adobe/aio-commerce-lib-config Minor
@adobe/aio-commerce-lib-app Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added with-changeset The PR contains a Changeset file. pkg: aio-commerce-lib-config Includes changes in `packages/aio-commerce-lib-config` labels Apr 15, 2026
@obarcelonap obarcelonap force-pushed the CEXT-6073/add-id-to-config-origin branch from 834f6a3 to 9e5eca0 Compare April 15, 2026 20:27
name: field.name,
value: field.default as string,
origin: { code: "default", level: "system" },
origin: { id: "default", code: "default", level: "system" },
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think that we need to change this to global for both code and level. What do you think?

Also this id being default it bugs me. IDs should always be a UUID, maybe we should search the scope with that code and level and grab the id from it. I am not sure if there's any with code: default and level: system, by default, but we should have the code: global and level: global, which is the reason I suggested changing it.

name,
value: def,
origin: { code: "default", level: "system" },
origin: { id: "default", code: "default", level: "system" },
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Idem here

@obarcelonap
Copy link
Copy Markdown
Member Author

After analysis, we're not adding id to ConfigOrigin.
The original motivation was to let the UI determine whether a config value is inherited or locally set. id was proposed as the unambiguous comparator, but it's not needed:

  • code + level is already guaranteed unique across the scope tree — lib-config validates this and throws on duplicate code + level combinations
  • app-management never exposes level when creating scopes, so in practice code alone is sufficient there
  • The UI check simply becomes origin.code !== currentCode || origin.level !== currentLevel instead of origin.id !== currentId — no added complexity

The id: "default" sentinel for schema defaults (@iivvaannxx concern in https://github.com/adobe/aio-commerce-sdk/pull/389/changes#r3109982635) will be addressed separately by changing the origin to { code: "global", level: "global" }, which is the actual scope of CEXT-6105

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: aio-commerce-lib-config Includes changes in `packages/aio-commerce-lib-config` with-changeset The PR contains a Changeset file.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants