Skip to content

fix: require dataset_query.database in create_card to prevent NULL co…#14

Open
eric-summersault wants to merge 1 commit intoCognitionAI:mainfrom
eric-summersault:fix/create-card-error-handling
Open

fix: require dataset_query.database in create_card to prevent NULL co…#14
eric-summersault wants to merge 1 commit intoCognitionAI:mainfrom
eric-summersault:fix/create-card-error-handling

Conversation

@eric-summersault
Copy link
Copy Markdown

…nstraint errors

Root cause: When calling create_card, the database_id was null causing:
"ERROR: null value in column "database_id" of relation "report_card" violates not-null constraint"

Changes:

  • Make dataset_query required with database, type fields validated by Zod
  • Make display required (Metabase API requirement)
  • Filter payload to only include valid Metabase card fields (prevents LLMs from passing extra fields that could break the API)
  • Default visualization_settings to {} if not provided
  • Improve error handling to include Metabase API response details

Added test infrastructure (Vitest) with tests covering:

  • Proper payload structure for create_card
  • Required database ID validation
  • Extra field filtering
  • Error message extraction

Fixes #9

🤖 Generated with Claude Code

…nstraint errors

Root cause: When calling create_card, the database_id was null causing:
"ERROR: null value in column "database_id" of relation "report_card" violates not-null constraint"

Changes:
- Make dataset_query required with database, type fields validated by Zod
- Make display required (Metabase API requirement)
- Filter payload to only include valid Metabase card fields (prevents LLMs from passing extra fields that could break the API)
- Default visualization_settings to {} if not provided
- Improve error handling to include Metabase API response details

Added test infrastructure (Vitest) with tests covering:
- Proper payload structure for create_card
- Required database ID validation
- Extra field filtering
- Error message extraction

Fixes CognitionAI#9

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

create_card tool fails with 500 errors while direct API calls succeed

1 participant