Skip to content

[SVLS-10161] feat: route feature flag config through the extension when no API key is set - #1522

Open
purple4reina wants to merge 2 commits into
mainfrom
rey.abolofia/ffe-extension-base-url
Open

purple4reina wants to merge 2 commits into
mainfrom
rey.abolofia/ffe-extension-base-url

Conversation

@purple4reina

@purple4reina purple4reina commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Jira: SVLS-10161

Java and .NET version of DataDog/datadog-lambda-python#890 and DataDog/datadog-lambda-js#867 (Ruby: DataDog/datadog-lambda-rb#173).

Problem

The tracer's feature flag provider loads flag config from Datadog's CDN with the API key from its own config. Customers who keep the key in DD_API_KEY_SECRET_ARN, DD_API_KEY_SSM_NAME or DD_KMS_API_KEY get PROVIDER_NOT_READY on every flag check.

This PR

#1510 added a route on the trace agent (127.0.0.1:8126) that forwards the config request with the key the extension resolved. The tracer uses it only when DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_BASE_URL is set.

datadog_wrapper now sets DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_BASE_URL=http://127.0.0.1:8126 only when both are true:

  1. All of DD_API_KEY, DATADOG_API_KEY, DD_API_KEY_FILE, DD_PROFILING_API_KEY, DD_PROFILING_API_KEY_FILE, DD_PROFILING_APIKEY and DD_PROFILING_APIKEY_FILE are unset, empty or whitespace-only. That is every API key env var dd-trace-java reads, and it includes DD_API_KEY, the only one dd-trace-dotnet reads. DATADOG_API_KEY is there because dd-trace-js reads it as an alias, and Node uses this wrapper for AppSec: the extension does not read it, so routing those customers through the extension would break flags that work today.
  2. The customer has not set the base URL.

The default is set in the block that sets DD_TRACE_STATS_COMPUTATION_ENABLED, so it applies to every runtime that uses the wrapper.

Why these conditions

  • No API key: in the wrapper, unlike in the library layers, this is not needed for safety. The wrapper ships inside the extension, and this merges after [SVLS-10111] feat(traces): Forward feature flag config fetch requests via Extension with resolved API key #1510, so every extension with this code also has the route. The condition stays for the same blast radius as Python/Node: customers with a key keep the direct CDN path they use today, and only customers who are broken today change.
  • No extension check: the wrapper is part of the extension layer and image, so the extension is present.
  • Base URL not set: an explicit customer value wins.

Gotchas reviewers should know about

  • Minimum tracer versions: dd-trace-dotnet reads the variable from v3.53.0. The .NET layer v28 ships v3.57.0. In Java, the dd-openfeature SDK (an application dependency, not part of the layer) reads it from v1.68.0. Older versions ignore it.
  • Neither tracer sends DD-API-KEY or dd_env to a custom base URL. The extension adds the key, and it adds dd_env from DD_ENV (or env in DD_TAGS). So in .NET, an environment changed in code at runtime does not change the flag config environment.
  • Keys the wrapper cannot see: Java system properties (-Ddd.api-key, -Ddd.api-key-file, for example in JAVA_TOOL_OPTIONS), a Java DD_TRACE_CONFIG properties file, or .NET datadog.json / DD_TRACE_CONFIG_FILE. These customers go through the extension, which works because the route exists and the extension uses its own key. The wrapper does not parse these sources.
  • Whitespace-only keys count as unset. dd-trace-java trims them to nothing. dd-trace-dotnet sends them to the CDN, and the CDN rejects them.
  • Other runtimes that use the wrapper (for example Python or Node with AppSec) get the same default the libraries set under the same condition. Tracers that do not know the variable, including non-Datadog tracers, ignore it.
  • Extension cannot resolve the key (wrong ARN, missing IAM permission): the route returns 403.
  • Port is hard-coded to 8126. The extension's trace agent always listens there in Lambda.
  • DD_FEATURE_FLAGS_CONFIGURATION_SOURCE=remote_config or DD_FEATURE_FLAGS_ENABLED=false: the base URL applies only to the agentless source, so it has no effect.

Testing

The repo has no wrapper tests.

Test 1: env matrix

Steps

  1. With env -i, run the wrapper under bash 3.2 and bash 5 with AWS_EXECUTION_ENV set to Java 21, .NET 8 and Python 3.12. Pass printenv DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_BASE_URL as the command.
  2. Run 12 cases: no key, empty key, whitespace key, DD_API_KEY_SECRET_ARN only, each of the key variables set, and a customer base URL with and without DD_API_KEY.

Result

All 12 cases pass on every runtime. The wrapper on main fails the 4 no-key cases.

Test 2: shellcheck

Steps

  1. Run shellcheck on the old and new wrapper.

Result

No new findings.

🤖 Generated with Claude Code

…en no API key is set

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@purple4reina
purple4reina requested a review from a team as a code owner November 17, 2026 06:49
@purple4reina
purple4reina requested review from litianningdatadog and a balanced review from Copilot November 17, 2026 06:49
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T06:50:27.161410Z e516cba PR opened
ℹ️ 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.

dd-trace-js reads DATADOG_API_KEY as an alias of DD_API_KEY, and Node
uses this wrapper for AppSec. The extension does not read that variable,
so routing those customers through it would break flags that work today.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the wrapper’s conditional feature-flag proxy configuration.

No open issues 🎉

What changed in this PR

Updates the Lambda runtime wrapper to route feature flag configuration requests through the extension’s existing proxy when no supported API key environment variable contains a non-whitespace value. This lets tracers use the API key resolved by the extension.

Changes:

  • Checks all six API key environment variables supported by Java before setting the default.
  • Defaults the feature flag base URL to http://127.0.0.1:8126, preserving any non-empty customer override.
File Description
scripts/​datadog_wrapper Adds conditional feature flag proxy configuration for runtimes using the wrapper.

Review effort: Balanced

Comment thread scripts/datadog_wrapper
# extension, which adds the key it resolved (e.g. from DD_API_KEY_SECRET_ARN).
# The variables are every API key setting dd-trace-java reads, plus
# DATADOG_API_KEY, which dd-trace-js reads (Node uses this wrapper for AppSec).
if [[ "$DD_API_KEY$DATADOG_API_KEY$DD_API_KEY_FILE$DD_PROFILING_API_KEY$DD_PROFILING_API_KEY_FILE$DD_PROFILING_APIKEY$DD_PROFILING_APIKEY_FILE" =~ ^[[:space:]]*$ ]]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My only concern is this could potentially break customers who set their API key only in a Java system property or a Java/.NET config file. The wrapper can’t see those keys and will set the local base URL. The tracer then sends the request without its key, so the extension returns 403 if it doesn’t have a key of its own.

@litianningdatadog litianningdatadog left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Left some comment. Let me know if I missed something or am over concerned.

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