| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
| }); | ||
| }); | ||
|
|
||
| // Ref: https://github.com/aclark4life/specifications/blob/feaec8d0ca332a80f457f75c6ef1600267e61d64/source/mongodb-handshake/tests/README.md#test-3-test-that-agent-metadata-is-properly-captured |
There was a problem hiding this comment.
The new spec and unit tests need to clean up the env vars before starting, so the developer's local variables do not impact the tests.
Sorry, something went wrong.
| const agentEnv = getAgentEnv(); | ||
|
|
||
| const fullEnv = new Map<string, unknown>(); | ||
| if (containerMetadata.size > 0) fullEnv.set('container', containerMetadata); |
There was a problem hiding this comment.
With this insertion order, container data is dropped before faas. Current (main) implementation tries to re-add container after faas gets booted, so this is a change in behavior.
Sorry, something went wrong.
| * Resolves `env.agent` from the environment, or an empty string when no agent variable is | ||
| * populated. Returns the value of the first populated variable in `AGENT_ENV_VARIABLES`. | ||
| */ | ||
| export function getAgentEnv(): string { |
There was a problem hiding this comment.
This function should be added to test/mongodb_bundled.ts (alphabetically next to getFAASEnv) for the bundled tests to succeed.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Description
Summary of Changes
Adds an AI agent identifier, env.agent, to the client metadata handshake, and refactors how the env sub-document is built and truncated.
env.agent
env.agent is populated using first-match, order-bound logic over the agent-related environment variables defined in the spec. Depending on which variable matches, the value is either a generic marker (AI_AGENT / AGENT) or the variable's literal value.
Per the spec, "a variable is considered populated if it is present in the environment with a non-empty value." We treat any value that is empty after trim() as unpopulated and skip it. Populated values are used as-is (e.g. ' claude' is kept verbatim).
env construction and truncation
The spec's truncation order is:
Previously, env was built by progressively appending members to the live metadata document, and the spec was partially-satisfied somewhat incidentally: env.name happened to be the last FaaS member added, so it was deleted last — but env.container iss appended after that, making it theoretically possible to end up with an env containing only container.
env is now constructed as a standalone document, truncated independently. This prepare us for a future spec alignment effort tracked in https://jira.mongodb.org/browse/NODE-7851
Refer to: mongodb/specifications#1967 for the incoming changes.
Notes for Reviewers
What is the motivation for this change?
For bug fixes
Current (incorrect) behavior:
Expected behavior:
How to reproduce:
Affected versions:
Release Highlight
Release notes highlight
Double check the following