Skip to content

fix(artifacts): bound auto-generated artifact names to 128 characters - #12755

Open
somuai wants to merge 1 commit into
wandb:mainfrom
somuai:fix-autogen-artifact-name-maxlen
Open

somuai wants to merge 1 commit into
wandb:mainfrom
somuai:fix-autogen-artifact-name-maxlen

Conversation

@somuai

@somuai somuai commented Sep 7, 2026

Copy link
Copy Markdown

Description

When client-side artifact name validation was added in #9594, validate_artifact_name(name) strictly enforces len(name) <= 128. However, internal auto-generated artifact names (such as run tables created via InternalArtifact(f"run-{run.id}-{key}", "run_table"), incremental tables created via _get_artifact_name(run, key), or default names generated when logging files via log_artifact) could exceed 128 characters when table keys or filenames are long. This caused unpredictable ValueError: Artifact name is longer than 128 characters errors on valid user workflows.

Changes

  1. Updated sanitize_artifact_name(name: str) -> str in wandb/sdk/artifacts/_internal_artifact.py to enforce NAME_MAXLEN = 128. Names longer than 128 characters (or with characters sanitized) are safely truncated using middle ellipsis while preserving the 6-character CRC32 suffix to prevent collection name collisions.
  2. Handled edge case where sanitized prefix is empty (e.g. input composed purely of stripped characters) by defaulting to "artifact".
  3. Ensured default artifact names auto-generated in Run.log_artifact() (wandb/sdk/wandb_run.py) are passed through wandb.util.make_artifact_name_safe when name is omitted.
  4. Added comprehensive test coverage in tests/unit_tests/test_artifacts/test_internal_artifact.py covering preservation of valid names, character sanitization, length bounding, idempotency, uniqueness, and InternalArtifact initialization with long keys.
  5. Added unit test cases for validate_artifact_name in tests/unit_tests/test_artifacts/test_validators.py.
  6. Updated CHANGELOG.unreleased.md.
  • I updated CHANGELOG.unreleased.md, or it's not applicable

Testing

  • Executed unit tests with pytest:
    • tests/unit_tests/test_artifacts/test_internal_artifact.py (15 passed)
    • tests/unit_tests/test_artifacts/test_validators.py (89 passed)
  • Verified idempotency and character constraints across edge cases (len=129, len=200, len=500).
  • Checked code formatting and linting via ruff check and ruff format.

@somuai
somuai requested review from a team as code owners September 7, 2026 08:25
@somuai
somuai force-pushed the fix-autogen-artifact-name-maxlen branch 2 times, most recently from cda3fff to 708a896 Compare September 10, 2026 14:42
…wandb#11212)

Enforce NAME_MAXLEN (128 characters) in sanitize_artifact_name so that
auto-generated internal artifact names (e.g. run tables, incremental tables)
do not exceed client-side validator constraints and cause unexpected
ValueErrors. Long names are truncated with middle ellipsis while preserving
the CRC32 collision-prevention suffix. Also ensure default artifact names
generated in log_artifact are passed through make_artifact_name_safe.

Signed-off-by: Soumyajit Ghosh <jobsoumyajit6124@gmail.com>
@somuai
somuai force-pushed the fix-autogen-artifact-name-maxlen branch from 708a896 to 9a20cfb Compare October 5, 2026 19:53
@wandbot-3000

wandbot-3000 Bot commented Oct 5, 2026

Copy link
Copy Markdown

📋 Code Owner Summary

This PR modifies 5 files.

Each section below is a group of files and their owners from CODEOWNERS. Approval is required from one owner in each group.

Legend: ✅ approval acquired, 🟠 approval still required, 👀 advisory/informational only.

Send a review request to a team's channel by adding a notify:<team> label to the PR.

🟠 @wandb/sdk-team — approval still required

🟠 @wandb/art-reg-team, @wandb/sdk-team — approval still required


Automatically updated by wandbot from the mergeability check.

@somuai

somuai commented Oct 5, 2026

Copy link
Copy Markdown
Author

Update:

  • Cleanly rebased onto latest upstream/main (eeab17a).
  • Resolved merge conflict in CHANGELOG.unreleased.md.
  • Preserved CRC32 collision-prevention suffix and middle ellipsis truncation for auto-generated internal artifact names.

Ready for review.

This branch has not been deployed

No deployments
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.

Inconsistent restriction: ValueError: Artifact name is longer than 128 characters

1 participant