Skip to content

feat: Bedrock Guardrail configs support environment variable assignment#11717

Open
entropic489 wants to merge 1 commit intodanny-avila:mainfrom
newjersey:josh/bedrock-guardrail-config-loading
Open

feat: Bedrock Guardrail configs support environment variable assignment#11717
entropic489 wants to merge 1 commit intodanny-avila:mainfrom
newjersey:josh/bedrock-guardrail-config-loading

Conversation

@entropic489
Copy link

@entropic489 entropic489 commented Feb 10, 2026

Summary

Supports loading Bedrock guardrailConfig items from environment variables, using the existing extractEnvVariable() method.

Change Type

  • New feature (non-breaking change which adds functionality)

Testing

I've added tests in the Bedrock initialize.spec.ts to ensure env var expansion is working as expected.

Test Configuration:

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • My changes do not introduce new warnings
  • I have written tests demonstrating that my changes are effective or that my feature works
  • Local unit tests pass with my changes

@entropic489 entropic489 changed the title bedrock config loading feat: Bedrock Guardrail configs support environment variable assignment Feb 10, 2026
@danny-avila danny-avila requested a review from Copilot February 12, 2026 03:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support for resolving ${ENV_VAR} placeholders inside Bedrock guardrailConfig entries during initialization, aligning guardrail configuration with existing env-var expansion behavior used elsewhere in the Bedrock setup.

Changes:

  • Resolve guardrailIdentifier and guardrailVersion via extractEnvVariable() when guardrailConfig is provided.
  • Add unit tests validating env-var expansion behavior (including whitespace and missing env var fallback) for guardrail config fields.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/api/src/endpoints/bedrock/initialize.ts Expands env-var placeholders for guardrail identifier/version when building llmConfig.guardrailConfig.
packages/api/src/endpoints/bedrock/initialize.spec.ts Adds coverage for env-var expansion scenarios for Bedrock guardrail configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +124 to +126
guardrailIdentifier: extractEnvVariable(bedrockConfig.guardrailConfig.guardrailIdentifier),
guardrailVersion: extractEnvVariable(bedrockConfig.guardrailConfig.guardrailVersion),
trace: bedrockConfig.guardrailConfig.trace,
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

To avoid duplicating the GuardrailConfiguration shape (and potentially dropping new fields if the type/API expands later), consider spreading the existing bedrockConfig.guardrailConfig and only overriding the resolved fields (guardrailIdentifier/guardrailVersion). This keeps behavior consistent if additional properties are added in the future.

Suggested change
guardrailIdentifier: extractEnvVariable(bedrockConfig.guardrailConfig.guardrailIdentifier),
guardrailVersion: extractEnvVariable(bedrockConfig.guardrailConfig.guardrailVersion),
trace: bedrockConfig.guardrailConfig.trace,
...bedrockConfig.guardrailConfig,
guardrailIdentifier: extractEnvVariable(bedrockConfig.guardrailConfig.guardrailIdentifier),
guardrailVersion: extractEnvVariable(bedrockConfig.guardrailConfig.guardrailVersion),

Copilot uses AI. Check for mistakes.
Comment on lines +207 to +212
it('should resolve environment variables in guardrailIdentifier', async () => {
const guardrailId = 'gr-abc123xyz';
process.env.GUARDRAIL_ID = guardrailId;

const params = createMockParams({
config: {
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

The new env-var expansion tests are very similar and add a lot of repeated setup/assertions. Consider consolidating these into a parameterized test (e.g., it.each) and/or a small helper to set env + build params, to keep the spec file easier to maintain as cases evolve.

Copilot uses AI. Check for mistakes.
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.

2 participants