Skip to content

Fix appsec compressed data support for v1 deser#6392

Open
ajgajg1134 wants to merge 2 commits intomainfrom
andrew.glaude/appSecv1
Open

Fix appsec compressed data support for v1 deser#6392
ajgajg1134 wants to merge 2 commits intomainfrom
andrew.glaude/appSecv1

Conversation

@ajgajg1134
Copy link
Contributor

Motivation

Turns out these fields aren't always just raw json, but can also be base64 encoded gzipped data.

Changes

Check for [ to decide how to deserialize. (The RFC recommends this approach). Also make errors more explicit to make debugging issues easier.

Workflow

  1. ⚠️ Create your PR as draft ⚠️
  2. Work on you PR until the CI passes
  3. Mark it as ready for review
    • Test logic is modified? -> Get a review from RFC owner.
    • Framework is modified, or non obvious usage of it -> get a review from R&P team

🚀 Once your PR is reviewed and the CI green, you can merge it!

🛟 #apm-shared-testing 🛟

Reviewer checklist

  • Anything but tests/ or manifests/ is modified ? I have the approval from R&P team
  • A docker base image is modified?
    • the relevant build-XXX-image label is present
  • A scenario is added, removed or renamed?

@github-actions
Copy link
Contributor

CODEOWNERS have been resolved as:

tests/test_the_test/test_deserializer.py                                @DataDog/system-tests-core
utils/proxy/_deserializer.py                                            @DataDog/system-tests-core
utils/proxy/traces/trace_v1.py                                          @DataDog/system-tests-core

@ajgajg1134 ajgajg1134 marked this pull request as ready for review February 27, 2026 18:36
@ajgajg1134 ajgajg1134 requested a review from a team as a code owner February 27, 2026 18:36
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 91c8778045

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +112 to +119
if s.startswith("["):
try:
return json.loads(value)
except json.JSONDecodeError as e:
raise ValueError(f"Invalid JSON for _dd.appsec.s.* value: {e}") from e
try:
decoded = base64.b64decode(value, validate=True)
except Exception as e:

Choose a reason for hiding this comment

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

P2 Badge Accept raw JSON objects for appsec schema values

The new decoder only treats payloads as raw JSON when they start with [; every other valid JSON form (for example {...} or "...") is now forced down the base64+gzip path and fails with Invalid base64. This is a behavioral regression from the previous implementation, which fell back to json.loads(payload) for any non-compressed payload, so tracers that emit uncompressed non-array JSON for _dd.appsec.s.* will now fail deserialization.

Useful? React with 👍 / 👎.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fine since the RFC requires that uncompressed payloads begin with [

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