Skip to content

bug(assets): NONE-auth gateways generate invalid Python (over-indented else) in googleadk/langchain/openaiagents templates #1520

Description

@aidandaly24

Description

The googleadk, langchain_langgraph, and openaiagents gateway client.py templates generate syntactically invalid Python whenever a gateway uses the NONE authorizer type. The auth-type {{#if}}/{{else}}/{{/if}} Handlebars block is indented inside an if url: clause that is immediately followed by else:; the indented control tags leave stray whitespace that over-indents the Python else: (rendering else: instead of else:), producing an IndentationError at import time.

NONE is a valid, user-reachable gateway authorizer type (GatewayAuthorizerTypeSchema = z.enum(['NONE', 'AWS_IAM', 'CUSTOM_JWT'])), so any agent with a no-auth gateway in one of these frameworks fails to run. Strands is structurally immune (it uses an if not url: return None shape with no trailing Python else:).

Steps to Reproduce

  1. agentcore create --project-name demo --no-agent
  2. agentcore add gateway --name public --authorizer-type NONE
  3. agentcore add gateway-target --gateway public --name a --type mcp-server --endpoint https://mcp.exa.ai/mcp
  4. agentcore add agent --name demo --framework GoogleADK --model-provider Bedrock --memory none (also reproduces with LangChain_LangGraph and OpenAIAgents)
  5. Inspect app/demo/mcp_client/client.py — or run the agent

Expected Behavior

The generated client.py is valid Python with the else: at the correct 4-space indent, for every authorizer type including NONE.

Actual Behavior

The rendered client.py contains an over-indented else:, raising IndentationError: unexpected indent when the module is imported.

CLI Version

main (0.19.0)

Operating System

Linux

Additional Context

Root cause is indented standalone Handlebars control tags. Moving {{#if}}/{{else}}/{{/if}} to column 0 makes Handlebars strip them as standalone lines, keeping the Python else: correctly indented. Fixed in #1518.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions