← Back to Pull requests

Trim whitespace for ENC[...] references to match Agent #3786

Closed
unknown closed this pull request without merging on Nov 16, 2026 17:55 UTC
View on GitHub
unknown unknown commented on Nov 13, 2026 13:01 UTC
Author

What does this PR do?

Trims leading/trailing spaces and tabs before matching ENC[...] secret references in pkg/secrets, matching the Agent's comp/core/secrets/utils.IsEnc.

  • parseEnc trims once and returns the handle; IsEnc and extractHandle use it.

  • fetchSecret keys results by the original input instead of rebuilding ENC[<handle>], so callers can look up padded references without changes. For unpadded inputs the keys are identical to before. encFormat is removed as unused.
  • Motivation

    CONTP-2323. Per the brief, credentials and DDGR secret references (CONTP-2284) should share the Agent's matching behavior.

    Additional Notes

  • A padded value like " ENC[handle]\t" is now resolved through the secret backend instead of being used as a literal key. With no backend configured, it now fails at credential loading with a secret-backend error.

  • Exact references, literal values and decrypted values are unchanged. Only spaces and tabs are trimmed, as in the Agent.
  • Minimum Agent Versions

    N/A

    Describe your test plan

  • Unit tests in pkg/secrets and pkg/config cover padded references and trimming boundaries (newlines, padded literals).

  • Local deployment on minikube with --secretBackendCommand=/readsecret.sh reading a mounted Secret, and API endpoints pointed at an in-cluster echo server to capture the Dd-Api-Key header:

  • - Padded ENC[...] references in DD_API_KEY/DD_APP_KEY (e.g. " ENC[api_key]\t") resolve, and metadata requests use the decrypted key.
    - A padded ENC[...] reference in a DatadogAgent's spec.global.credentials.apiKey resolves for the metrics forwarder (validate, events, series).
    - Unpadded ENC[...] references in both places still resolve.
    - Control: the previous image sends padded references as the raw ENC[...] string.

    Checklist

  • PR has at least one valid label: bug, enhancement, refactoring, documentation, tooling, and/or dependencies

  • PR has a milestone or the qa/skip-qa label

  • All commits are signed (see: [signing commits][1])
  • [1]: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits

    [CONTP-2323]: https://datadoghq.atlassian.net/browse/CONTP-2323?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
    [CONTP-2284]: https://datadoghq.atlassian.net/browse/CONTP-2284?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

    Diff: 342 lines (+256 / -86) across 4 files Reviewer: gabedos Review duration: 4614m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 342 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.349
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3786"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.3% (MEDIUM) · Higher = larger blast radius
    42.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.7% · Safe to merge
    16.7%