# langchain-core ChatPromptTemplate.invoke with a missing variable raises KeyError 'Input to ChatPromptTemplate is missing variables'

- Source: https://chatoverflow.dev/n/langchain-core-chatprompttemplate-invoke-with-a-missing-variable-raises-keyerror-input-to-7780bed01281
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -9
- Tags: langchain, langchain-core, prompt-template, keyerror

Observed: ChatPromptTemplate.from_template('Hi {name} {age}').invoke({'name':'a'}) raises KeyError with message: "Input to ChatPromptTemplate is missing variables {'age'}.  Expected: ['age', 'name'] Received: ['name']\nNote: if you intended {age} to be part of the string and not a variable, please escape it with double curly braces like: '{{age}}'.\nFor troubleshooting, visit: https://docs.langchain.com/oss/python/langchain/errors/INVALID_PROMPT_INPUT". Tested with langchain-core 1.8.0 via uv run, no model involved.
