I use Datadog in my day-to-day work, so I'm interested in the small integration details that make it easier to operate.
One recent contribution started with a configuration mismatch: Prefect supports a combined username:password credential, while Datadog's Prefect integration expected those values separately.
Supporting the combined value sounded straightforward. The more interesting part turned out to be what happens to that credential after configuration is loaded—especially when someone generates a diagnostic bundle.
The change is now merged in DataDog/integrations-core PR #25596.
The configuration mismatch
Self-hosted Prefect supports HTTP Basic authentication. Its server can use PREFECT_SERVER_API_AUTH_STRING, and clients use the matching PREFECT_API_AUTH_STRING value.
Both hold a combined credential, such as username:password.
Datadog already supported authentication through separate username and password options. The request in issue #25512 was to accept the combined format too.
For a deployment that already manages a combined secret, that avoids having to split it simply to configure monitoring. It doesn't add a new authentication method; it adds another way to supply the existing credentials.
The final option is prefect_userpass:
instances:
- prefect_url: https://prefect.example/api
prefect_userpass: ENC[prefect_api_auth_string]
Here, prefect_api_auth_string is an illustrative secret identifier that must resolve through the Agent's configured secrets-management mechanism. ENC[...] doesn't configure that mechanism by itself.
The check also doesn't automatically read Prefect's environment variables. You explicitly supply the credential through Datadog configuration. Existing separate-credential configurations remain supported.
Split once, then use the existing HTTP client
A password can contain a colon. Treating every colon as a separator would break a valid credential.
The implementation separates the username from the remainder at the first colon:
# Illustrative values, not real credentials
username, _, password = "worker:demo:with:colons".partition(":")
assert username == "worker"
assert password == "demo:with:colons"
Those values go through Datadog's existing HTTP wrapper, rather than introducing a second request path with its own authentication handling.
Validation belongs with configuration
Review feedback helped separate two kinds of validation.
The credential's shape belongs in the configuration specification: a non-empty username, a separator, and a non-empty password. Datadog's tooling generates the corresponding model constraint.
Rules involving multiple settings belong in check_instance, after configuration defaults have been applied. For example, the combined option must not be used alongside separate username or password settings, or with a non-basic authentication type.
That keeps request code focused on making requests. Invalid combinations fail during initialization, before a request is sent.
Why the name changed to prefect_userpass
This was the part of the review that stuck with me.
The setting was initially named auth_string. A later suggestion was to give it a Prefect-specific name to avoid a possible future collision with a generic HTTP option.
Then a maintainer pointed out another concern: the Agent's flare scrubber uses key-name rules to redact sensitive configuration values. Neither auth_string nor prefect_auth_string matched the relevant rules discussed in the review.
Marking the option secret: true in the integration specification wasn't enough to provide that runtime redaction.
The final name, prefect_userpass, includes pass, allowing it to match the existing password scrubber rule. The reasoning is documented in the maintainer's review comment.
I found that a useful reminder: a configuration key's name can affect how other parts of the system handle its value. Parsing a secret correctly is only one part of the job. Error messages and diagnostic tooling need attention too.
Secret references and HTTPS still matter; redaction isn't a replacement for either.
Test what reaches the request
The regression tests exercise the prepared HTTP request and inspect its Authorization header. That checks more than whether a string was split correctly.
They cover combined credentials, passwords containing colons, mixed-case basic-auth settings, existing separate credentials, and unauthenticated configuration.
Invalid-configuration tests check that initialization raises a configuration error, sends no request, and doesn't include the sample secret in the error message.
The HTTP transport is mocked. These tests verify request preparation and configuration behavior; they aren't a live Prefect deployment or an Agent end-to-end test. They also don't independently prove flare redaction—the naming decision follows the existing scrubber behavior identified during review.
The lesson I'll take into the next integration
This was a small feature, but it touched configuration schemas, generated models, HTTP behavior, diagnostic redaction, documentation, and tests.
The review made the contribution more useful and gave me a better way to think about credentials: follow the value beyond the point where it's parsed. Check where it might appear when configuration fails or someone needs help debugging.
When you review a new credential setting, do you check what ends up in the diagnostic bundle too?
References
- Merged contribution and discussion
- Original feature request
- Prefect self-hosted security settings
- Datadog Agent secrets management
The configuration above reflects the merged change. Check that your installed Prefect integration version includes prefect_userpass before using it.
Top comments (0)