Skip to content

Regenerate C schema headers for Policy.id string field#77

Merged
annacai21 merged 2 commits into
mainfrom
anna.cai/expose-current-policy-id
Jul 10, 2026
Merged

Regenerate C schema headers for Policy.id string field#77
annacai21 merged 2 commits into
mainfrom
anna.cai/expose-current-policy-id

Conversation

@annacai21

@annacai21 annacai21 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

This PR regenerates the C schema headers (policy_reader.h, policy_builder.h, policy_verifier.h) via flatcc, which were stale since Policy.id changed from a UUID struct to a string in #74.

@annacai21 annacai21 requested a review from a team as a code owner July 9, 2026 23:10
@annacai21 annacai21 changed the title Expose current policy id via eval_ctx getter feat(eval_ctx): expose current policy id via getter Jul 9, 2026
@annacai21 annacai21 force-pushed the anna.cai/expose-current-policy-id branch from bd89a17 to 3fee540 Compare July 9, 2026 23:13
@annacai21 annacai21 changed the title feat(eval_ctx): expose current policy id via getter Expose current policy id via eval_ctx getter Jul 9, 2026
@datadog-official

datadog-official Bot commented Jul 9, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 21.66%

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 31159b8 | Docs | Datadog PR Page | Give us feedback!

/** Stable identifier for this policy, used to attribute an evaluation outcome
* back to its source. For Remote Config policies this is the rule's UUID;
* for hardcoded/built-in policies it is the sentinel "hardcoded". */
__flatbuffers_define_string_field(3, dd_wls_Policy, id, 0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Are we sure this is backward compatible with existing policies already in flatbuffer?

@annacai21 annacai21 Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. This would be a breaking wire-format change for any buffer where id was already populated. However, I checked both ways a Policy buffer gets built and confirmed that neither of them already populated the id field:

  1. dd-policy-engine's converters never called PolicyAddId anywhere in this repo before PR Stamp hardcoded policies with id="hardcoded" #75
  2. RC policies are compiled via dd-compile-policy from JSON, but that JSON has never contained a real id either.

Since FlatBuffers vtables mark an unset field as explicitly absent, every buffer compiled by either path so far has that slot empty, and the new reader will correctly see the field absent rather than reinterpreting old struct bytes as a string offset. This would only be unsafe if some buffer out there already had a real non-zero id, and nothing does yet.

@annacai21 annacai21 changed the title Expose current policy id via eval_ctx getter Regenerate C schema headers for Policy.id string field Jul 10, 2026

@natitsechanski natitsechanski left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

@annacai21 annacai21 merged commit 82925d7 into main Jul 10, 2026
14 checks passed
@annacai21 annacai21 deleted the anna.cai/expose-current-policy-id branch July 10, 2026 18:28
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.

3 participants