Skip to content

fix: return DimensionValuesError when dimension column absent from Arrow result#828

Merged
b-per merged 2 commits into
mainfrom
fix/get-dimension-values-keyerror
Jun 30, 2026
Merged

fix: return DimensionValuesError when dimension column absent from Arrow result#828
b-per merged 2 commits into
mainfrom
fix/get-dimension-values-keyerror

Conversation

@b-per

@b-per b-per commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Closes #827

Summary

  • get_dimension_values crashed with an unhandled KeyError when the Arrow table returned by the Semantic Layer SDK contained no column matching the requested dimension name (not even case-insensitively).
  • The next() fallback in client.py returned the raw dimension string, and raw_table.column(that_string) raised KeyError. The except block only caught QueryFailedError, so the error propagated unhandled to prod.
  • Fix: change the next() fallback to None and return DimensionValuesError with a clear message when no matching column is found.

Test plan

  • New test TestGetDimensionValues::test_dimension_column_absent_from_result_returns_error reproduces the exact prod error and passes after the fix
  • Full unit suite passes (744 passed)
  • task check clean (ruff, mypy, pre-commit)

…row result

When the Semantic Layer SDK returns an Arrow table that has no column
matching the requested dimension name (even case-insensitively), the
previous code fell back to the raw dimension string as the column name
and then called raw_table.column(), which raised an unhandled KeyError.

Now we check whether a matching column was found and return a
DimensionValuesError with a clear message instead of crashing.

Closes #827
Copilot AI review requested due to automatic review settings June 30, 2026 09:36
@b-per b-per requested review from a team, jairus-m and jasnonaz as code owners June 30, 2026 09:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a production crash path in the semantic-layer dimension values fetcher by converting a missing Arrow column (previously raising an unhandled KeyError) into a structured DimensionValuesError, and adds a unit test to prevent regression.

Changes:

  • Update get_dimension_values to detect when the requested dimension column is absent from the returned Arrow table schema and return DimensionValuesError instead of triggering KeyError.
  • Add a unit test that reproduces the “dimension column absent” scenario and asserts an error result is returned.
  • Add an unreleased changelog entry documenting the bug fix.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/dbt_mcp/semantic_layer/client.py Prevents unhandled KeyError by returning DimensionValuesError when no schema column matches the requested dimension.
tests/unit/semantic_layer/test_client.py Adds regression coverage for missing-dimension-column Arrow results.
.changes/unreleased/Bug Fix-20260630-104909.yaml Records the bug fix in the changelog system.

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

Comment thread src/dbt_mcp/semantic_layer/client.py
@b-per

b-per commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

Fixed in 5fdaa84 — error message now includes the available schema columns (addresses Copilot's inline suggestion).

@b-per b-per merged commit f9bea3c into main Jun 30, 2026
8 of 9 checks passed
@b-per b-per deleted the fix/get-dimension-values-keyerror branch June 30, 2026 14:01
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.

get_dimension_values raises unhandled KeyError when dimension column absent from Arrow result

3 participants