Fix appsec compressed data support for v1 deser#6392
Fix appsec compressed data support for v1 deser#6392ajgajg1134 wants to merge 2 commits intomainfrom
Conversation
|
|
There was a problem hiding this comment.
💡 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".
| 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: |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
This fine since the RFC requires that uncompressed payloads begin with [
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
🚀 Once your PR is reviewed and the CI green, you can merge it!
🛟 #apm-shared-testing 🛟
Reviewer checklist
tests/ormanifests/is modified ? I have the approval from R&P teambuild-XXX-imagelabel is present