Skip to content

refactor: audit broad except sites in ops.py#255

Merged
hachej merged 1 commit intorefactor/xorq-shimfrom
refactor/except-audit
May 5, 2026
Merged

refactor: audit broad except sites in ops.py#255
hachej merged 1 commit intorefactor/xorq-shimfrom
refactor/except-audit

Conversation

@hussainsultan
Copy link
Copy Markdown
Collaborator

Stacked PR — 2 of 3

This PR is stacked on top of #254 (refactor/xorq-shim). It targets that branch, not main. Read in order:

Each PR in the stack is independently green. Once #254 merges, GitHub will retarget this PR to main automatically.

Summary

Walked all 26 broad except Exception blocks in ops.py and made a per-site call. Results:

Decision Count What
Narrowed 4 3 ImportError (xorq imports inside try); 1 (AttributeError, TypeError) for _is_mean_expr's duck-type probe
Logged 8 Silent fallbacks now logger.debug(..., exc_info=True) so backend-compat / probing failures are observable in development without flooding production logs
Kept broad 14 Intentional patterns — predicate-probing loops, repr fallbacks, Result-pattern wrappers, dim-resolution recovery via _extract_missing_column_name

Why

The audit started from the concern that broad except Exception blocks in ops.py could turn user errors (typo'd column, bad lambda) into silent wrong results instead of clear errors.

After walking each site: most are legitimate xorq/ibis API-drift fallbacks or intentional probing loops — but they were silent, which made debugging harder than it needed to be. Adding logger.debug with exc_info=True keeps the fallback behavior identical while making failures visible when you turn debug logging on.

What's logged now

  • from_ibis fallback when backend isn't xorq-supported (e.g. Databricks)
  • walk_nodes failures on plain ibis trees (3 sites)
  • Join-defer eligibility check failures
  • Full-join chasm fallback to per-table path
  • Dimension/measure graph traversal fallbacks during column-requirement extraction

Non-goals

  • No behavior change. Production behavior unchanged unless you set the BSL logger to DEBUG.

Test plan

  • 930 unit tests pass (no regressions vs. parent branch)
  • No tests started failing or passing differently
  • Narrowed ImportError sites still trigger their fallback when xorq is fully installed (sanity-checked)

🤖 Generated with Claude Code

Walked all 26 except Exception blocks. Result:

- 4 narrowed to specific types: 3 ImportError sites (xorq imports
  inside try blocks, only ImportError makes sense) and 1 (AttributeError,
  TypeError) for _is_mean_expr's duck-type probe.
- 8 silent fallbacks now log at logger.debug with exc_info so backend-
  compat / probing failures are observable in development without
  flooding production logs. These cover from_ibis fallback, walk_nodes
  on plain ibis trees, join-defer eligibility checks, full-join chasm
  fallback, and column-requirement traversal fallbacks.
- The remaining 22 broad excepts are intentional: predicate-probing
  loops that test whether a filter applies to a given table, repr
  fallbacks that must never raise, Result-pattern wrappers that
  re-encapsulate any exception, and the dim-resolution loop that
  recovers via _extract_missing_column_name.

No behavior change. 930 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <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.

2 participants