Skip to content

feat: add find command for catalog search#174

Open
nadavs123 wants to merge 66 commits intomicrosoft:mainfrom
nadavs123:feature/catalog-search-find-command
Open

feat: add find command for catalog search#174
nadavs123 wants to merge 66 commits intomicrosoft:mainfrom
nadavs123:feature/catalog-search-find-command

Conversation

@nadavs123
Copy link
Copy Markdown

@nadavs123 nadavs123 commented Feb 15, 2026

Pull Request

Closes #172

Summary

Adds a new find command that searches for Fabric items across all accessible workspaces using the Catalog Search API (POST /v1/catalog/search).

Usage

# Basic search
fab find "sales report"

# Filter by item type
fab find "data" -P type=Lakehouse

# Multiple types (bracket syntax)
fab find "dashboard" -P type=[Report,SemanticModel]

# Exclude a type
fab find "data" -P type!=Dashboard

# Exclude multiple types
fab find "data" -P type!=[Dashboard,Datamart]

# Show detailed output with IDs
fab find "sales" -l

# Project specific fields with JMESPath
fab find "data" -q "[].{name: name, workspace: workspace}"

Flags

Flag Description
-P/--params Filter in key=value or key!=value format. Brackets for multiple values: type=[Lakehouse,Notebook]
-l/--long Show detailed table with IDs (name, id, type, workspace, workspace_id, description)
-q/--query JMESPath query for client-side filtering

Implementation details

  • Follows existing CLI patterns: @handle_exceptions decorator, print_output_format(), FabricCLIError
  • Item type list in type_supported.yaml (included in package-data, matching command_supported.yaml pattern)
  • Error messages in ErrorMessages.Find class (matches repo pattern)
  • Interactive mode: page-by-page with "Press Enter to continue..." prompt
  • Command-line mode: fetches all pages automatically
  • _parse_type_from_params uses get_dict_from_params for parameter parsing with != regex support
  • _fetch_results shared helper for response parsing and pagination
  • truncate_columns in fab_util.py for terminal-width-aware column sizing (reusable by other commands)
  • JMESPath filtering applied before column truncation; truncation only affects text output

Files added

  • src/fabric_cli/client/fab_api_catalog.py — API client (search() function)
  • src/fabric_cli/commands/find/__init__.py — Package init
  • src/fabric_cli/commands/find/fab_find.py — Command logic
  • src/fabric_cli/commands/find/type_supported.yaml — Supported/unsupported item types
  • src/fabric_cli/errors/find.pyFindErrors class
  • src/fabric_cli/parsers/fab_find_parser.py — Argument parser
  • docs/commands/find.md — Command documentation
  • tests/test_commands/test_find.py — 15 e2e VCR tests
  • tests/test_commands/recordings/test_commands/test_find/*.yaml — VCR cassettes
  • tests/test_commands/api_processors/catalog_search_api_processor.py — Cassette processor for catalog search responses

Files modified

  • src/fabric_cli/core/fab_parser_setup.py — Register find parser
  • src/fabric_cli/errors/__init__.py — Register Find error class
  • src/fabric_cli/utils/fab_util.py — Add truncate_columns(), != regex support in get_dict_from_params
  • tests/test_commands/commands_parser.py — Register find parser + Windows PromptSession fix (scoped with try/finally)
  • tests/test_commands/api_processors/api_processor_handler.py — Register CatalogSearchAPIProcessor
  • pyproject.toml — Add type_supported.yaml to package-data
  • MANIFEST.in — Add type_supported.yaml to source distribution

Notes

  • Dashboard is the only unsupported item type (not searchable)
  • Dataflow Gen1/Gen2 are not searchable; only Dataflow Gen2 CI/CD is returned (as type Dataflow)
  • Scorecards are returned as type Report
  • Requires Catalog.Read.All scope

@nadavs123 nadavs123 requested a review from a team as a code owner February 15, 2026 09:54
Comment thread src/fabric_cli/commands/find/fab_find.py Outdated
Comment thread src/fabric_cli/commands/find/fab_find.py Outdated
Comment thread src/fabric_cli/commands/find/fab_find.py Outdated
Comment thread src/fabric_cli/client/fab_api_catalog.py Outdated
Comment thread src/fabric_cli/commands/find/fab_find.py Outdated
Comment thread src/fabric_cli/parsers/fab_find_parser.py
Comment thread src/fabric_cli/parsers/fab_find_parser.py
Comment thread issue-172.md Outdated
Comment thread tests/test_commands/find/__init__.py
Comment thread tests/test_commands/find/test_find.py Outdated
@aviatco
Copy link
Copy Markdown
Collaborator

aviatco commented Mar 15, 2026

Please update the description:

fab find "monthly" --type Report Warehouse - should be list

fab find "dashboard" --max-items 10 - flag doesnt exist

fab find --next-token "eyJTa2lwIjoy..." - flag doesnt exist

Comment thread src/fabric_cli/commands/find/__init__.py
nadavs123 pushed a commit to nadavs123/fabric-cli that referenced this pull request Mar 16, 2026
Changes:
- Move type lists to type_supported.yaml (loaded at import)
- Create FindErrors class for error messages
- Rename catalog_search -> search in fab_api_catalog
- Extract _fetch_results helper (shared by interactive/commandline)
- Add try-except JSONDecodeError around json.loads
- Refactor while True -> while has_more
- Rename detailed -> show_details, _parse_type_param -> _parse_type_from_params
- Single-loop _display_items
- Move truncate_descriptions to fab_util.py
- Fix 'total item(s)' -> 'item(s) shown'
- Remove redundant comments
- Parser: remove required=False, change -P nargs to '?'
- Handle both string and list params (backward compat)
- _split_params respects brackets and merges legacy comma values
- Delete issue-172.md
- Flatten test dir: tests/test_commands/test_find.py (43 tests)
- Add docs/commands/find.md

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread docs/commands/find.md
Comment thread docs/commands/find.md Outdated
Comment thread docs/commands/find.md Outdated
Comment thread docs/commands/find.md Outdated
Comment thread src/fabric_cli/commands/find/fab_find.py Outdated
Comment thread tests/test_commands/test_find.py Outdated
Comment thread tests/test_commands/test_find.py Outdated
Comment thread tests/test_commands/test_find.py Outdated
Comment thread tests/test_commands/test_find.py
Comment thread tests/test_commands/test_find.py
Comment thread src/fabric_cli/commands/find/fab_find.py Outdated
Comment thread src/fabric_cli/utils/fab_util.py
Comment thread tests/test_commands/test_find.py Outdated
Copilot AI review requested due to automatic review settings March 29, 2026 12:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new top-level fab find command that searches Fabric items across all accessible workspaces via the Catalog Search API (POST /v1/catalog/search), integrating with existing CLI output/error patterns and adding unit + VCR-backed E2E coverage.

Changes:

  • Introduces find command implementation, parser registration, and supported-type allow/deny lists.
  • Adds a dedicated Catalog API client wrapper for catalog/search.
  • Extends shared utilities (get_dict_from_params to support !=, plus a new truncate_columns helper) and adds tests + VCR recordings + docs.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/fabric_cli/commands/find/fab_find.py Implements find command logic, paging, filtering, JMESPath support, and output formatting.
src/fabric_cli/commands/find/type_supported.yaml Declares searchable vs unsupported item types for catalog search.
src/fabric_cli/commands/find/__init__.py Adds find command package.
src/fabric_cli/client/fab_api_catalog.py Adds API client wrapper for POST /v1/catalog/search.
src/fabric_cli/parsers/fab_find_parser.py Adds argparse parser, flags, help, and examples for find.
src/fabric_cli/core/fab_parser_setup.py Registers find with the global parser setup.
src/fabric_cli/errors/find.py Adds FindErrors message helpers.
src/fabric_cli/errors/__init__.py Registers ErrorMessages.Find.
src/fabric_cli/errors/common.py Adds common error helpers used by param parsing (unsupported_parameter, invalid_parameter_format).
src/fabric_cli/errors/config.py Removes config-specific invalid_parameter_format helper (superseded by common).
src/fabric_cli/utils/fab_util.py Updates param parsing to accept != and adds truncate_columns() for table-fit truncation.
docs/commands/find.md Documents find usage, flags, and examples.
tests/test_commands/commands_parser.py Registers find parser in test CLI harness and adjusts Windows PromptSession handling.
tests/test_commands/test_find.py Adds unit tests + VCR-backed E2E tests for find behaviors.
tests/test_commands/recordings/test_commands/test_find/test_find_basic_search_success.yaml VCR cassette for basic search.
tests/test_commands/recordings/test_commands/test_find/test_find_with_type_filter_success.yaml VCR cassette for type= filtering.
tests/test_commands/recordings/test_commands/test_find/test_find_type_case_insensitive_success.yaml VCR cassette for case-insensitive type=.
tests/test_commands/recordings/test_commands/test_find/test_find_with_long_output_success.yaml VCR cassette for --long output.
tests/test_commands/recordings/test_commands/test_find/test_find_no_results_success.yaml VCR cassette for empty results.
tests/test_commands/recordings/test_commands/test_find/test_find_with_ne_filter_success.yaml VCR cassette for type!= filtering.
tests/test_commands/recordings/test_commands/test_find/test_find_ne_multi_type_success.yaml VCR cassette for type!=[...].
tests/test_commands/recordings/test_commands/test_find/test_find_multi_type_eq_success.yaml VCR cassette for type=[...].
tests/test_commands/recordings/test_commands/test_find/test_find_with_jmespath_query_success.yaml VCR cassette for -q/--query behavior.
tests/test_commands/recordings/test_commands/test_find/test_find_json_output_success.yaml VCR cassette for --output_format json.
tests/test_commands/recordings/test_commands/test_find/test_find_search_summary_success.yaml VCR cassette for summary output.
.changes/unreleased/added-20260209-171617.yaml Adds unreleased changelog entry for the new command.

Comment thread src/fabric_cli/utils/fab_util.py
Comment thread tests/test_commands/test_find.py Outdated
Comment thread src/fabric_cli/commands/find/fab_find.py Outdated
Comment thread src/fabric_cli/commands/find/fab_find.py Outdated
Comment thread src/fabric_cli/commands/find/fab_find.py Outdated
Comment thread tests/test_commands/test_find.py Outdated
Comment thread tests/test_commands/test_find.py Outdated
Comment thread tests/test_commands/test_find.py Outdated
Comment thread tests/test_commands/test_find.py Outdated
Comment thread tests/test_commands/test_find.py Outdated
Comment thread tests/test_commands/test_find.py Outdated
Copilot AI review requested due to automatic review settings April 13, 2026 15:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 29 out of 29 changed files in this pull request and generated 7 comments.

Comment thread src/fabric_cli/commands/find/fab_find.py
Comment thread src/fabric_cli/commands/find/fab_find.py
Comment thread src/fabric_cli/commands/find/fab_find.py Outdated
Comment thread src/fabric_cli/parsers/fab_find_parser.py
Comment thread docs/commands/find.md Outdated
Comment thread tests/test_commands/api_processors/catalog_search_api_processor.py
Comment thread tests/test_commands/commands_parser.py
Copilot AI review requested due to automatic review settings April 14, 2026 10:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Comment thread src/fabric_cli/commands/find/fab_find.py Outdated
Comment thread src/fabric_cli/commands/find/fab_find.py Outdated
Comment thread src/fabric_cli/commands/find/fab_find.py Outdated
Comment thread src/fabric_cli/commands/find/fab_find.py Outdated
Comment thread src/fabric_cli/commands/find/fab_find.py Outdated
Comment thread src/fabric_cli/commands/find/fab_find.py
Comment thread src/fabric_cli/commands/find/fab_find.py Outdated
Comment thread src/fabric_cli/commands/find/fab_find.py Outdated
Copilot AI review requested due to automatic review settings April 15, 2026 13:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

tests/test_commands/test_find.py:1

  • The explicit time.sleep(30) calls will significantly slow the test suite when running in playback mode unless they are reliably patched by mock_time_sleep. If the sleep is only needed during cassette recording / eventual consistency, consider conditioning it on record mode (or removing it entirely for playback) to keep CI fast and deterministic.

Comment thread src/fabric_cli/commands/find/fab_find.py Outdated
Comment thread src/fabric_cli/parsers/fab_find_parser.py
Comment thread src/fabric_cli/utils/fab_util.py Outdated
Comment thread src/fabric_cli/commands/find/fab_find.py Outdated
Nadav Schachter added 6 commits April 15, 2026 17:16
Features:
- Search across all workspaces by displayName, workspaceName, or description
- Filter by item type with --type flag
- Limit results with --limit flag
- Detailed output with --detailed flag (includes id, workspaceId)
- Custom endpoint support with --endpoint flag or FAB_CATALOG_ENDPOINT env var

Output columns (default): name, type, workspace, description
Output columns (detailed): + workspaceId, id

Required scope: Catalog.Read.All
Unsupported types: Dashboard, Dataflow, Scorecard

Includes unit tests (12 tests passing)
…dling

Changes based on issue microsoft#172 feedback:
- Changed --type from comma-separated to nargs='+' (space-separated)
- Removed --endpoint flag (use internal mechanism instead)
- Added FabricCLIError for invalid/unsupported item types
- Added error handling for API failures
- Updated tests to match new patterns (15 tests passing)
- Added complete_item_types() completer for searchable types
- Tab completion excludes unsupported types (Dashboard, Dataflow, Scorecard)
- Restored unsupported type validation with clear error message
- Updated ALL_ITEM_TYPES list from official API spec
- Added SEARCHABLE_ITEM_TYPES for valid filter types
- 20 tests passing
- Keep tab-completion for --type flag
- Custom FabricCLIError for unsupported types (Dashboard, Dataflow, Scorecard)
- Custom FabricCLIError for unknown types
- Cleaner error messages vs argparse choices listing all 40+ types
- 22 tests passing
- Changed from data= to json= for request payload
- Added raw_response=True to avoid auto-pagination hanging
- Added fallback from displayName to name (API bug workaround)
- Updated tests to use dict instead of JSON string
- Successfully tested against dailyapi.fabric.microsoft.com
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 36 out of 36 changed files in this pull request and generated no new comments.

Nadav Schachter and others added 2 commits April 19, 2026 15:49
Add TestFindTruncation class with 3 synthetic-cassette tests:

- text output truncates 256-char names (ellipsis present)

- detail mode (-l) preserves full names

- JSON output preserves full names

Uses handcrafted cassettes (same pattern as TestFindPagination)

because the test harness normalizes names during recording.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Default format_type to 'text' when neither args.output_format nor

FAB_OUTPUT_FORMAT config returns a value. Previously fell through

to the unsupported-format error with 'None'.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 19, 2026 13:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 39 out of 39 changed files in this pull request and generated 5 comments.

Comment thread src/fabric_cli/utils/fab_ui.py
Comment thread src/fabric_cli/commands/find/fab_find.py Outdated
Comment thread src/fabric_cli/commands/find/fab_find.py
Comment thread src/fabric_cli/commands/find/fab_find.py
Comment thread src/fabric_cli/commands/find/fab_find.py
Skip column truncation when JMESPath projection produces a list of scalars. truncate_columns() expects dict items and would crash on .keys() otherwise.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread src/fabric_cli/utils/fab_ui.py Outdated
Comment thread tests/test_commands/test_find.py
Comment thread tests/test_commands/test_find.py
Copilot AI review requested due to automatic review settings April 20, 2026 09:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 39 out of 39 changed files in this pull request and generated 3 comments.

Comment thread src/fabric_cli/utils/fab_util.py
Comment thread src/fabric_cli/commands/find/fab_find.py
Comment thread tests/test_commands/processors.py
The default is already set by init_defaults via FAB_OUTPUT_FORMAT config.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
aviatco
aviatco previously approved these changes Apr 20, 2026
Add assert for continuation_token narrowing (str | None -> str) and

use intermediate variable for JMESPath search result to avoid

incompatible assignment types.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 20, 2026 13:00
Comment thread src/fabric_cli/commands/find/fab_find.py Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 39 out of 39 changed files in this pull request and generated 1 comment.

Comment thread src/fabric_cli/utils/fab_util.py Outdated
Nadav Schachter and others added 2 commits April 20, 2026 16:13
Remove guard breaks; accept token as str | None instead.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace has_more_pages boolean with while continuation_token is not None.

Mypy narrows the type inside the loop body, so _next_page_payload

keeps its correct token: str signature.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 20, 2026 13:28
Use items[0].keys() instead of union of all rows, matching

get_data_keys() which the renderer uses for column selection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 39 out of 39 changed files in this pull request and generated 2 comments.

Comment thread tests/test_commands/test_find.py
Comment thread src/fabric_cli/utils/fab_util.py
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.

[FEATURE] Add find command for catalog search

3 participants