fix: return DimensionValuesError when dimension column absent from Arrow result#828
Merged
Conversation
…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
Contributor
There was a problem hiding this comment.
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_valuesto detect when the requested dimension column is absent from the returned Arrow table schema and returnDimensionValuesErrorinstead of triggeringKeyError. - 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.
Collaborator
Author
|
Fixed in 5fdaa84 — error message now includes the available schema columns (addresses Copilot's inline suggestion). |
wiggzz
approved these changes
Jun 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #827
Summary
get_dimension_valuescrashed with an unhandledKeyErrorwhen the Arrow table returned by the Semantic Layer SDK contained no column matching the requested dimension name (not even case-insensitively).next()fallback inclient.pyreturned the raw dimension string, andraw_table.column(that_string)raisedKeyError. Theexceptblock only caughtQueryFailedError, so the error propagated unhandled to prod.next()fallback toNoneand returnDimensionValuesErrorwith a clear message when no matching column is found.Test plan
TestGetDimensionValues::test_dimension_column_absent_from_result_returns_errorreproduces the exact prod error and passes after the fix744 passed)task checkclean (ruff, mypy, pre-commit)