Skip to content

feat(py-client): Validate and encode custom metadata keys - #789

Open
jan-auer wants to merge 3 commits into
mainfrom
claude/python-custom-metadata-keys-ee59cd
Open

jan-auer wants to merge 3 commits into
mainfrom
claude/python-custom-metadata-keys-ee59cd

Conversation

@jan-auer

@jan-auer jan-auer commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Custom metadata keys travel in HTTP header names (x-snme-<key>), but the Python client sent them as given. A key with a space, a non-ASCII character or an uppercase letter went into the header name unchecked. A % or : in a key was also not escaped.

The client now applies explicit key rules before it sends anything:

  • A key is lowercased, then must be non-empty and use only a-z, 0-9 and _ - | ~ % $ # + . :.
  • An invalid key raises ValueError naming the key. This happens in put() before any request is sent, on both the regular and the resumable upload path.
  • In the header name, % is sent as %25 and : as %3a.
  • When reading a response, key names are fully percent-decoded. %3a and %3A both become :, and %253a becomes the literal %3a. A % that is not followed by two hex digits stays as it is. A key with invalid UTF-8 raises UnicodeDecodeError.

The Rust client and the server follow the same key rules.

Ref FS-599

Changelog Entry

  • Custom metadata keys are now lowercased and validated: put() raises ValueError for a key that is empty or uses characters other than a-z, 0-9 and _ - | ~ % $ # + . :.

@github-actions

Copy link
Copy Markdown

Semver Impact of This PR

This PR lands in these workspaces:

  • clients/python: 🟡 Minor (new features)
📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features

  • Custom metadata keys are now lowercased and validated: put() raises ValueError for a key that is empty or uses characters other than a-z, 0-9 and _ - | ~ % $ # + . :. by jan-auer in #789

🤖 This preview updates automatically when you update the PR.

@codecov

codecov Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.53%. Comparing base (f88d941) to head (c1b12c6).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #789      +/-   ##
==========================================
- Coverage   92.03%   91.53%   -0.50%     
==========================================
  Files         120      120              
  Lines       23514    23698     +184     
==========================================
+ Hits        21640    21691      +51     
- Misses       1874     2007     +133     
Components Coverage Δ
Rust Backend 94.18% <ø> (-0.79%) ⬇️
Rust Client 88.82% <ø> (-0.32%) ⬇️
Python Client 91.75% <100.00%> (+0.11%) ⬆️

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@linear-code

linear-code Bot commented Nov 12, 2026

Copy link
Copy Markdown

FS-599

@jan-auer
jan-auer marked this pull request as ready for review November 16, 2026 10:57
@jan-auer
jan-auer requested a review from a team as a code owner November 16, 2026 10:57
@lcian lcian changed the title feat(python): Validate and encode custom metadata keys feat(py-client): Validate and encode custom metadata keys Nov 16, 2026

@lcian lcian left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me.

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.

2 participants