Skip to content

fix: pdf base64 encode tracestate header#1645

Open
martinothamar wants to merge 1 commit intomainfrom
fix/pdf-base64-encode-tracestate
Open

fix: pdf base64 encode tracestate header#1645
martinothamar wants to merge 1 commit intomainfrom
fix/pdf-base64-encode-tracestate

Conversation

@martinothamar
Copy link
Contributor

@martinothamar martinothamar commented Jan 28, 2026

Description

See comment, CDP/pdf3 complained about invalid cookies, was able to narrow it down to tracestate. Today we "trust" extend whatever W3C trace context is passed into app APIs. In this specific case, SBS system had baggage in spans which where propagated through tracestate header (as per spec). Values can contain semicolons. Cookie values can not contain semicolons (tested by invoking Network.setCookies through CDP manually)

{
        "domain": "brg.apps.tt02.altinn.no",
        "name": "altinn-telemetry-tracestate",
        "sameSite": "Lax",
        "value": "dd=s:1;o:rum"
}

Related Issue(s)

  • N/A

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)
  • All tests run green

Documentation

  • User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)

Summary by CodeRabbit

  • Bug Fixes
    • Improved trace context handling in the PDF generation service to ensure proper encoding of telemetry data according to W3C standards.

✏️ Tip: You can customize this high-level summary in your review settings.

@martinothamar martinothamar self-assigned this Jan 28, 2026
@martinothamar martinothamar added kind/bug Something isn't working bugfix Label Pull requests with bugfix. Used when generation releasenotes backport This PR should be cherry-picked onto older release branches labels Jan 28, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 28, 2026

📝 Walkthrough

Walkthrough

The PDF generator client now base64-encodes the tracestate cookie value when propagating W3C trace context headers to PDF generation requests. Other cookies and the traceparent header remain unaffected.

Changes

Cohort / File(s) Summary
PDF generator cookie encoding
src/Altinn.App.Core/Infrastructure/Clients/Pdf/PdfGeneratorClient.cs
Base64-encodes the tracestate cookie value before adding it to request cookies; traceparent and other cookies remain unchanged

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: pdf base64 encode tracestate header' is directly related to the main change, which is base64-encoding the tracestate cookie value in PDF generator client code to resolve CDP cookie validation issues.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/pdf-base64-encode-tracestate

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/Altinn.App.Core/Infrastructure/Clients/Pdf/PdfGeneratorClient.cs`:
- Around line 107-121: Backend correctly base64-encodes tracestate cookie values
in PdfGeneratorClient (see PdfGeneratorCookieOptions and the
"altinn-telemetry-{k}" cookie creation), but you must ensure the PDF
viewer/frontend repository implements the matching decoding for the
altinn-telemetry-tracestate cookie before merging; coordinate with frontend
owners to add logic that decodes base64 from the altinn-telemetry-tracestate
cookie (or header) and verifies it is propagated back unchanged, and add a short
integration test or manual verification checklist in the frontend repo to
confirm the end-to-end contract.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
50.0% Condition Coverage on New Code (required ≥ 65%)

See analysis details on SonarQube Cloud

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

Labels

backport This PR should be cherry-picked onto older release branches bugfix Label Pull requests with bugfix. Used when generation releasenotes kind/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants