Skip to content

feat(ingest/powerbi): parse report and page filters from report definitions - #20881

Open
brock-acryl wants to merge 12 commits into
feat/powerbi-refresh-schedulefrom
feat/powerbi-report-filters
Open

brock-acryl wants to merge 12 commits into
feat/powerbi-refresh-schedulefrom
feat/powerbi-report-filters

Conversation

@brock-acryl

@brock-acryl brock-acryl commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

With extract_report_field_usage:

  • Report-level and page-level filters are parsed from PBIR and the legacy single-file format, with target field, type and a readable condition (In ["CA"], >= 1000, Last 30 days, Top 5 by [Total Premium]).
  • Emitted as a JSON filters list plus filterCount on the report and its pages; every field a filter reads joins the page's inputFields.
  • Conditions are capped (500 chars, In lists at 20 values, 50 filters per property with filtersTruncated). Conditions include the literal values compared against; the docs say so.
  • A report definition that fails to parse is a warning with report_definitions_failed, never a lost report.

Stack

Part of a stack built on #20842 (Power BI metadata_api_mode: workspace_apis). Merge order:
#20876 → #20877 → #20878 → #20879 → #20880 → #20881 → #20882 → #20883 → #20884 → #20885.
Review this PR's own diff against its base branch; each layer is self-contained and tested on its own.

Checklist

  • PR title follows the Conventional Commits format
  • Tests added/updated (unit and integration goldens)
  • Docs updated (metadata-ingestion/docs/sources/powerbi/)
  • No breaking change (behind extract_report_field_usage, default off)

🤖 Generated with Claude Code

@codecov

codecov Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.70968% with 4 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...werbi/rest_api_wrapper/report_definition_parser.py 98.38% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

brock-acryl and others added 3 commits November 25, 2026 02:29
Review follow-ups for the report/page filter parsing:

- A legacy `filters` value that is not a JSON string is recorded as a
  failed filter instead of raising; a parser crash on one report is a
  `Report Definition Not Parsed` warning for that report only.
- `ReportFilter.fields` lists every model field a filter reads (target
  first), so a TopN's ordering measure reaches the page's inputFields;
  `target` is strictly the declared field. A filter with neither a target
  nor a condition is a parse failure, with the exception recorded.
- Rendered conditions are bounded: `In [...]` shows 20 values, conditions
  are capped at 500 chars, and the `filters` property keeps 50 filters with
  `filtersTruncated` and a `report_filters_truncated` counter.
- `datasetEdges` on a report are emitted in sorted order so the golden file
  is deterministic.
- Structure: `_from_aliases`, `_dict_at`, per-operator renderers behind a
  dispatch table, `ParsedReportDefinition.page_field_refs`, legacy/PBIR
  filter helpers, `Constant` keys for the serialized filter and `scope` in
  `to_dict`.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- `report_definitions_failed` counts reports whose definition the parser
  could not handle (the `Report Definition Not Parsed` path).
- A renderer test case covers the 500-character condition cap.
- Docs and the `extract_report_field_usage` description note that a
  filter's rendered condition includes the literal values it compares
  against, which may be business data.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Regenerate the workspace_apis golden so the filter-targeted input fields carry
their model properties, and restore import spacing after the rebase.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@brock-acryl
brock-acryl force-pushed the feat/powerbi-report-filters branch from 125135b to 6161ea2 Compare November 25, 2026 07:31
@brock-acryl
brock-acryl marked this pull request as ready for review November 25, 2026 15:42
@cursor

cursor Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

PR Summary

Overview
When extract_report_field_usage is on, the Power BI connector now parses report-level and page-level filters from Fabric report definitions (PBIR and legacy report.json), not only visual field usage.

Filters are emitted as JSON filters, filterCount, and optional filtersTruncated on report dashboards and page charts. Filter targets and condition-derived fields join each page's inputFields; conditions are human-readable where possible (with caps on list size, string length, and max 50 filters per property). Docs call out that conditions may contain business literals.

The report definition parser gains substantial filter parsing and condition rendering; patch metadata paths explicitly remove stale filter custom properties when a run no longer emits them. New reporter counters and warnings cover parse/truncate failures without failing the whole report.

Reviewed by Cursor Bugbot for commit 778abba. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor 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.

Stale Bugbot comment from a previous run.

Report-level filters apply to every page, so a REST page the report
definition does not describe still gets their fields as inputFields.

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

@cursor cursor 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.

Stale Bugbot comment from a previous run.

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

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 13 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Document that filters come only from a fetched and parsed report
definition, the 50-entry, 500-character, 20-value and raw-JSON caps,
and add tests for the condition shapes the renderer falls back on.

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

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

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

@alokr-dhub alokr-dhub 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.

Looks good. Verified report- and page-level filter parsing across PBIR and legacy formats, condition rendering and truncation caps (50 filters with filtersTruncated and full filterCount, 500-char rendered conditions, 20 In values, 200-char raw JSON fallback), unmatched-page report-filter field deduplication, and non-fatal warning handling when filters or definitions fail to parse. Filter emission stays gated behind default-off extract_report_field_usage, with the literal-value disclosure documented in both config and source docs.

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1611bde. Configure here.

…erties

With patch_metadata the dashboardInfo patch only adds custom properties,
so filters, filterCount or filtersTruncated that a later run no longer
emits stayed on the report. With extract_report_field_usage on, the patch
now also removes the filter keys this run does not set.

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

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 3 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

View guided diff | Turn on auto-fix | Re-trigger cubic

brock-acryl and others added 2 commits December 2, 2026 11:23
GitHub kept a stale merge preview from before 65766d1 and reports a
conflict although the base branch is fully contained.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keeps the test file's import block identical to master's apart from the
new DashboardPatchBuilder import, so the stack merges cleanly onto master.

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

This branch was successfully deployed

1 active deployment
Preview — 778abbab Deployed Dec 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ingestion PR or Issue related to the ingestion of metadata

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants