Skip to content

Support obfuscated feature flag assignment keys - #3941

Open
leoromanovsky wants to merge 8 commits into
developfrom
flag-key-obfuscation
Open

leoromanovsky wants to merge 8 commits into
developfrom
flag-key-obfuscation

Conversation

@leoromanovsky

@leoromanovsky leoromanovsky commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Readable flag keys can reveal upcoming features. Support obfuscated assignments without changing application evaluation calls.
This reduces readable names in payloads; it does not hide values or prevent dictionary guessing. It is not encryption or response signing.

Changes and Decisions

Advertise support through this header instead of a JSON supported_capabilities field. Existing request fields stay unchanged.

X-DD-FEATURE-FLAGS-CAPABILITIES: assignment-encoding-flag-key-256-v1

Capabilities are sorted and comma-separated. They describe support, not a requirement. The edge still selects plaintext or obfuscated responses through its rollout.

For obfuscated: true, validate obfuscation: {scheme, salt} and hash the application key for lookup. The response scheme remains flag-key-sha256-v1:

lowercase_hex(SHA256(
  UTF8("datadog.feature-flags.flag-key.v1") || 0x00 ||
  decode_hex(salt) || UTF8(application_flag_key)
))

The public salt contains 16 bytes, encoded as 32 lowercase hexadecimal characters. Keys use exact UTF-8 bytes without normalization.

sequenceDiagram
    participant App
    participant SDK as Android Flags client
    participant Edge as Fastly
    SDK->>Edge: Precompute request + capability header
    Edge-->>SDK: Plaintext, or encoded keys + scheme + salt
    SDK->>SDK: Validate and retain assignments with encoding
    App->>SDK: Evaluate original flag key
    SDK->>SDK: Hash lookup key only for encoded assignments
    SDK-->>App: Original value and evaluation details
    SDK->>SDK: Keep original flag key in telemetry
Loading
  • Cache up to 1,024 lookup hashes per descriptor. Do not cache flag values or change exposure deduplication.
  • Use platform SHA-256. Update assignments and encoding together. Evaluation calls and original-key telemetry stay unchanged.
  • Notify first-flags listeners only for readable assignments. Return an empty key list for encoded configurations because original keys cannot be enumerated.
  • Persist encoded assignments under encodedFlags with their metadata and context. Continue reading legacy plaintext caches.
  • Advertise support only for native Android consumers. Block encoded cache reads until local source detection confirms support. React Native remains excluded.
  • Reject invalid encoding metadata without a plaintext retry. Preserve existing fallback behavior; failed context-switch behavior remains separate.
  • Keep API 23 compatibility and the existing JVM test structure. Add no application configuration or release tooling.

Release requires edge support for the new header. This PR does not deploy backend changes.

Related: edge rollout, browser implementation.

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Tests

✅ All CI checks and tests passed. Datadog automation helped this PR pass.

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🔄 Datadog retried 1 test - 1 passed on retry View in Datadog

🎯 Code Coverage (details)
• Patch Coverage: 94.29%
• Overall Coverage: 71.84% (+0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 1c1f39f | Docs | View more details | Give us feedback!

@leoromanovsky
leoromanovsky marked this pull request as ready for review October 5, 2026 22:19
@leoromanovsky
leoromanovsky requested review from a team as code owners October 5, 2026 22:19
@leoromanovsky
leoromanovsky requested review from typotter and vjfridge and removed request for a team October 5, 2026 22:19
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-07T18:04:04.732082Z 1c1f39f New commits
🔒 Security Review ✅ Completed 2026-10-07T18:05:55.369042Z 1c1f39f New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

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: 185a1fa917

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@RunWith(AndroidJUnit4::class)
internal class FlagKeyObfuscationDeviceTest {
@Test
fun resolvesEncodedAssignmentAfterCacheRoundTrip() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Follow the required test method naming convention

Rename this newly added camelCase test to the required M <expected behavior> W <method()> {context} format so the instrumentation test remains consistent and searchable alongside the rest of the suite.

AGENTS.md reference: AGENTS.md:L95-L95

Useful? React with 👍 / 👎.

@maciejburda
maciejburda requested a review from satween October 6, 2026 07:05

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think changes in this file are needed, given no instrumented test is required.

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

Copy link
Copy Markdown

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: b3779f8916

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +79 to +82
internal data class PrecomputedAssignments(
val flags: Map<String, PrecomputedFlag>,
val obfuscation: FlagKeyObfuscation? = null
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Register a factory for PrecomputedAssignments

This new data class is constructed repeatedly by the module's tests, but no corresponding ForgeryFactory was added or registered in ForgeConfigurator. Add and register the required factory so the new test model follows the module's fixture convention.

AGENTS.md reference: AGENTS.md:L99-L99

Useful? React with 👍 / 👎.

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.

Added and registered PrecomputedAssignmentsForgeryFactory in 751cb76. A repository test obtains the generated assignments through ForgeConfigurator and checks that setFlagsAndContext retains them. Flags JVM tests, ktlint, and Detekt pass.

typotter
typotter previously approved these changes Oct 6, 2026

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

Copy link
Copy Markdown

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: 751cb7629d

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}

@Test
fun `M restore latest salt and value W init { after multiple writes }`() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Name constructor tests after the invoked constructor

Fresh evidence after the earlier suite-wide naming comment is that this test and the native-cache test at line 232 still use W init, which is neither the required <method()> form nor the concrete constructor being exercised. Rename these labels to identify DefaultFlagsRepository() so the new tests comply with the repository's mandatory naming convention.

AGENTS.md reference: AGENTS.md:L95-L95

Useful? React with 👍 / 👎.

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.

Renamed both constructor tests to W DefaultFlagsRepository(). The develop merge also preserves the new first-flags callback. All 501 Flags tests and 76 OpenFeature tests pass, with ktlint and Detekt passing.

typotter
typotter previously approved these changes Oct 7, 2026
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