Skip to content

Web profiler's JS engine silently falls back on an unmatched cross pair, unlike the CLI #420

Description

@yakew7

Where: assets/profiler-engine.js's profile() (cross-handling, via its pickCross-equivalent) vs faircode/profiler.py:412-416.

The gap: the same class of divergence as the reference-validation gap (see companion issue) but for cross. Python's profile() raises when a requested cross pair doesn't match two real dimensions; the JS engine silently falls back to the first two detected dimensions instead, with no error.

Repro:

# Python
>>> profile(df, opts={"cross": ["sex", "nonexistent_col"]})
ValueError: cross column(s) don't match any profiled dimension: nonexistent_col
// JS - same input, no error, silently uses whichever two dimensions come first
const r = E.profile(table, {}, {cross: ['sex', 'nonexistent_col']});
r.intersections[0].dims  // ['sex', 'race'] - not what was asked for, no error

Why it matters: CONTRIBUTING.md explicitly requires the JS and Python engines to "keep... producing identical results" for the shared profiling logic - this is a real behavioral divergence in that shared API surface. Not reachable through profiler.html's UI today (the cross <select> dropdowns only ever offer real detected dimension names), but the divergence exists in the engine itself and would surface for any future caller that passes cross programmatically (a browser extension, a script embedding the engine, a future UI feature).

Suggested fix: port the same validation into the JS engine's cross-handling, matching the Python error message.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions