Skip to content

fix(styling): validate init_sd / column_config_overrides at the entry points - #986

Open
paddymul wants to merge 2 commits into
mainfrom
feat/979-validate-init-sd
Open

paddymul wants to merge 2 commits into
mainfrom
feat/979-validate-init-sd

Conversation

@paddymul

Copy link
Copy Markdown
Collaborator

Closes #979. Runtime half of #978.

Most display config never passes a type checker: it comes from notebook calls, JSON on the wire, and project files loaded through exec. Since #977 the base styling ignores the two malformed values it knows about (a non-dict ag_grid_specs, a non-list delete_keys). That keeps the column styled, but a typo now does nothing and says nothing. Others still crash in places that don't mention the config at all: a column entry that isn't a dict fails with 'str' object has no attribute 'get', and a non-dict init_sd fails with a bare dictionary update sequence error.

CustomizableDataflow.__init__ now checks init_sd and column_config_overrides before anything else runs. The widgets (pandas and polars), /load, /load_expr and the xorq dataflow all construct through it. Every known display config key has to hold its type's shape:

  • displayer_args, ag_grid_specs, color_map_config, tooltip_config and column_config_override are dicts
  • delete_keys is a list of str. A bare 'tooltip_config' is still accepted as the one key, since the intent is unambiguous.
  • highlight_regex and highlight_color are str, and highlight_phrase is a str or a list of str
  • merge_rule is 'hidden', the only value that does anything

Anything wrong raises one ValueError listing every problem with its column and key, so fixing a config doesn't take a round trip per typo. Unknown keys are left alone. An init_sd entry also carries summary stats, and hosts put keys the override type doesn't list, such as header_name, into column_config_overrides.

/load and /load_expr run the same check before touching the session or loading data. A bad config is a 400 invalid_display_config with the message and a problems list, not a 500 or a 200 with the key silently dropped.

The point-of-use guards in DefaultMainStyling.style_column stay. Entry validation can't see a value a ColAnalysis contributes to the sd from inside the pipeline.

The first commit adds the failing tests; the fix follows once CI has shown them failing.

🤖 Generated with Claude Code

…verrides at the entry points

A malformed display config key in init_sd or column_config_overrides should be
rejected where it enters, with one ValueError that names each column and key,
instead of being ignored by the styling guards or crashing somewhere unrelated.
Covers the dataflow constructor (and the pandas and polars widgets through it),
and /load and /load_expr, which should answer 400 invalid_display_config.

Unknown keys stay accepted: init_sd entries also carry summary stats, and hosts
set override keys like header_name that the override type doesn't list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b7b6ffa82f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +183 to +184
with pytest.raises(ValueError, match=key):
ACDFC(BASIC_DF, init_sd=init_sd)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add the validator exercised by these test cases

This commit changes only tests, while CustomizableDataflow.__init__ still accepts these values unchanged and DefaultMainStyling deliberately ignores a non-dict ag_grid_specs. Consequently this first parametrized case (and several of the new widget and HTTP expectations) fails with “DID NOT RAISE” rather than ValueError, so the proposed commit leaves the test suite red. Include the entry-point validation and server error mapping in the same change, rather than landing the intentionally failing tests alone.

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

📦 TestPyPI package published

pip install --index-strategy unsafe-best-match --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ buckaroo==0.15.8.dev36771714737

or with uv:

uv pip install --index-strategy unsafe-best-match --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ buckaroo==0.15.8.dev36771714737

MCP server for Claude Code

claude mcp add buckaroo-table -- uvx --from "buckaroo[mcp]==0.15.8.dev36771714737" --index-strategy unsafe-best-match --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ buckaroo-table

📖 Docs preview

🎨 Storybook preview

… points

validate_display_config checks that each display config key styling reads holds
its type's shape: displayer_args, ag_grid_specs, color_map_config,
tooltip_config and column_config_override are dicts, delete_keys a list of str
(a bare str still means the one key), highlight_* strings, merge_rule 'hidden'.
Everything wrong goes into one DisplayConfigError (a ValueError) naming the
column and key. Unknown keys pass: init_sd entries carry summary stats, and
overrides are merged straight over the column config.

CustomizableDataflow.__init__ runs it first, which covers the pandas and polars
widgets, /load and the xorq dataflow. /load and /load_expr also run it before
touching the session and answer 400 invalid_display_config with the problems.
The guards in DefaultMainStyling.style_column stay for values a ColAnalysis adds.

Closes #979

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@paddymul

paddymul commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator Author

Note for later work on this, not a blocker.

InitColMeta types every key that isn't display config as a stat through extra_items=SDVals, and SDBaseVals is Union[str, int, float, bool] (col_analysis.py:7). That isn't broad enough for the values stats actually hold. #1041 makes min/max keep the column's type on the xorq path (a ColumnValue marker), so a decimal column's min is now a Decimal there too.

What min() returns per backend, checked locally:

backend column value type
pandas int8, int64, Int64 numpy.int8, numpy.int64: not int subclasses
pandas uint64 numpy.uint64
pandas float32 numpy.float32: not a float subclass (numpy.float64 is)
pandas bool numpy.bool: not a bool subclass
pandas object column of Decimals decimal.Decimal
pandas datetime64, timedelta64 pd.Timestamp, pd.Timedelta
pandas all-null Int64, all-null datetime pd.NA, pd.NaT
polars Decimal decimal.Decimal
polars Date, Datetime, Duration, Time datetime.date, datetime.datetime, datetime.timedelta, datetime.time
polars all-null None
xorq (#1041) decimal128 decimal.Decimal
xorq int8, int64, uint64, float32 Python int / float
xorq all-null int64 float('nan')

mode and most_freq..5th_freq carry the same scalars, since they're values drawn from the column. None isn't in SDBaseVals either.

Nothing breaks today: the runtime check here only looks at display config keys and passes stat values through, and the sd travels as a plain dict. But whoever widens SDBaseVals will have to deal with the numpy scalar types, Decimal, the date/time types from both pandas and polars, and the null sentinels (None, pd.NA, pd.NaT).

🤖 Generated with Claude Code

This branch was successfully deployed

1 active deployment
testpypi — 3bba5d37 Deployed Sep 30, 2026 by paddymul via Publish to TestPyPI #1593
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.

styling: validate init_sd / column_config_overrides at the entry points (fast follow of #978)

1 participant