Skip to content

refactor!: Component identifier representation standardized - #204

Merged
dadrus merged 4 commits into
mainfrom
refactor/components_api
Nov 7, 2026
Merged

dadrus merged 4 commits into
mainfrom
refactor/components_api

Conversation

@dadrus

@dadrus dadrus commented Nov 7, 2026

Copy link
Copy Markdown
Owner

This PR introduces a breaking change to component identifier representation

Motivation

Previously, httpsig supported two representations of HTTP message component identifiers in WithComponents():

  • A simplified, unquoted syntax, such as @method or content-digest;req.
  • The RFC 9421 Structured Fields representation, such as "@method" or "content-digest";req.

However, the public API became inconsistent with the implementation of #166 and #176 in how these identifiers were returned:

  • SignatureRequest.Components contained serialized Structured Fields Items.
  • SignatureInfo.Components and VerifiedSignature.Components used simplified, unquoted identifiers as map keys.

This asymmetry could lead to surprising behavior. An identifier accepted by WithComponents() or returned by ParseAcceptSignature() could not necessarily be reused as a key when accessing the covered component values.

To eliminate this ambiguity, all public string-based component identifier APIs now consistently use the RFC 9421 Structured Fields Item representation.

Migration guide

Update component configuration

Before:

httpsig.WithComponents(
    "@method",
    "content-digest;req",
)

After:

httpsig.WithComponents(
    `"@method"`,
    `"content-digest";req`,
)

Previously valid unquoted identifiers now result in ErrInvalidComponentIdentifier when the option is applied.

Update component map lookups

Both SignatureInfo.Components, available during key resolution, and VerifiedSignature.Components, available after successful verification, now use serialized identifiers as keys.

Before:

method := info.Components["@method"]
digest := verified.Components["content-digest;req"]

After:

method := info.Components[`"@method"`]
digest := verified.Components[`"content-digest";req`]

@dadrus dadrus changed the title refactor!: Component identifier representation standardize refactor!: Component identifier representation standardized Nov 7, 2026
@codecov

codecov Bot commented Nov 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.96%. Comparing base (000f844) to head (7cbd6f2).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #204      +/-   ##
==========================================
- Coverage   97.98%   97.96%   -0.02%     
==========================================
  Files          23       23              
  Lines        1635     1623      -12     
==========================================
- Hits         1602     1590      -12     
  Misses         33       33              

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

@dadrus
dadrus merged commit 6e68062 into main Nov 7, 2026
10 checks passed
@dadrus
dadrus deleted the refactor/components_api branch November 7, 2026 23:05
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