Skip to content

feat!: Component.local_key -> Component.component_code#544

Draft
kdmccormick wants to merge 3 commits intokdmccormick/keys-collectionfrom
kdmccormick/keys-component
Draft

feat!: Component.local_key -> Component.component_code#544
kdmccormick wants to merge 3 commits intokdmccormick/keys-collectionfrom
kdmccormick/keys-component

Conversation

@kdmccormick
Copy link
Copy Markdown
Member

@kdmccormick kdmccormick commented Apr 15, 2026

Description

Renames the Component.local_key field to component_code, switching from key_field() to code_field() (stricter validation: [A-Za-z0-9-_.]+, max_length=255). Updates all API call sites, backup/restore, and tests.

Backup/restore now writes an [entity.component] section in each component TOML file containing component_type and component_code explicitly, so that restore does not need to parse the entity key. Old archives (without the [entity.component] section) are still accepted by falling back to the existing entity key parsing.

BREAKING CHANGE: Component.local_key has been renamed to Component.component_code.

BREAKING CHANGE: Component.component_code now validates against [A-Za-z0-9-_.]+ and has a max_length of 255. Previously local_key used key_field() (no regex validation, max_length=500).

BREAKING CHANGE: Function parameters renamed from local_key to component_code in create_component(...) and create_component_and_version(...).

BREAKING CHANGE: Functions get_component_by_key(...)/component_exists_by_key(...), renamed to get_component_by_code(...)/component_exists_by_code(...), and parameters renamed from local_key to component_code.

Part of: #322

Full series of PRs:

  1. feat!: Collection.key -> Collection.collection_code #542
  2. feat!: Component.local_key -> Component.component_code #544
  3. feat!: Add Container.container_code field #545
  4. feat!: Package and Entity keys are now opaque refs #546
  5. feat!: ComponentVersionMedia.key -> ComponentVersionMedia.path #547

Testing

TBC

AI disclosure

Claude helped me write this PR. See #322 for details.

kdmccormick and others added 2 commits April 16, 2026 12:49
Renames the Component.local_key field to component_code, switching
from key_field() to code_field() (stricter validation: [A-Za-z0-9\-\_\.]+,
max_length=255). Updates all API call sites, backup/restore, and tests.

Backup/restore now writes an [entity.component] section in each component
TOML file containing component_type and component_code explicitly, so that
restore does not need to parse the entity key. Old archives (without the
[entity.component] section) are still accepted by falling back to the
existing entity key parsing.

BREAKING CHANGE: Component.local_key has been renamed to Component.component_code.

BREAKING CHANGE: Component.component_code now validates against
[A-Za-z0-9\-\_\.]+  and has a max_length of 255. Previously local_key
used key_field() (no regex validation, max_length=500).

BREAKING CHANGE: Function parameters renamed from local_key to component_code
in create_component(...) and create_component_and_version(...).

BREAKING CHANGE: Functions get_component_by_key(...)/component_exists_by_key(...),
renamed to get_component_by_code(...)/component_exists_by_code(...), and
parameters renamed from local_key to component_code.

Part of: #322

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…base

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@kdmccormick kdmccormick force-pushed the kdmccormick/keys-collection branch from b3daece to d55764c Compare April 16, 2026 17:04
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@kdmccormick kdmccormick force-pushed the kdmccormick/keys-component branch from fbe4b4b to f4d32b8 Compare April 16, 2026 18:18
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.

1 participant