Skip to content

Optional {placeholder} headers throw on missing arg (renderHeaders not optional-aware; breaks Bedrock invoke/converse) #122

Description

@AtelyPham

Summary

Capabilities that declare optional {placeholder} headers fail when the optional arg is omitted: renderHeaders runs interpolate over every header value, and interpolate throws missing required argument: <name> on an absent placeholder. Body fields are optional-aware (a {placeholder} body field is dropped when absent unless listed in the schema required), but header rendering is not — so optional headers are de-facto mandatory.

Concretely this breaks amazon-bedrock model.invoke / model.converse, whose schemas mark accept / contentType optional but whose request declares headers: { accept: '{accept}', 'content-type': '{contentType}' }. Calling them without those args throws before the request is sent.

General declarative-REST behavior (not AWS-specific); surfaced during #113 / #118.

Evidence

  • src/connectors/adapters/declarative-rest.tsrenderHeaders maps each header through interpolate, which throws on a missing arg.
  • src/connectors/adapters/amazon-bedrock.tsmodel.invoke request headers { accept: '{accept}', 'content-type': '{contentType}' }; required: ['modelId', 'body'].

Repro

amazonBedrockConnector.executeMutation({ capabilityName: 'model.invoke',
  args: { modelId: 'anthropic.claude-3-sonnet-20240229-v1:0', body: {...} }, ... })
// → throws "missing required argument: accept"

Suggested fix

Make header interpolation optional-aware, mirroring renderObject for body fields: a header whose value is exactly {placeholder} is dropped when the arg is absent (unless the placeholder is in the capability's required list), instead of throwing.

Refs #113, #118.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions