feat: add find command for catalog search#174
feat: add find command for catalog search#174nadavs123 wants to merge 66 commits intomicrosoft:mainfrom
find command for catalog search#174Conversation
|
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 |
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>
There was a problem hiding this comment.
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
findcommand 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_paramsto support!=, plus a newtruncate_columnshelper) 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. |
There was a problem hiding this comment.
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 bymock_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.
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
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>
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>
The default is already set by init_defaults via FAB_OUTPUT_FORMAT config. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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>
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>
Pull Request
Closes #172
Summary
Adds a new
findcommand that searches for Fabric items across all accessible workspaces using the Catalog Search API (POST /v1/catalog/search).Usage
Flags
-P/--paramskey=valueorkey!=valueformat. Brackets for multiple values:type=[Lakehouse,Notebook]-l/--long-q/--queryImplementation details
@handle_exceptionsdecorator,print_output_format(),FabricCLIErrortype_supported.yaml(included in package-data, matchingcommand_supported.yamlpattern)ErrorMessages.Findclass (matches repo pattern)_parse_type_from_paramsusesget_dict_from_paramsfor parameter parsing with!=regex support_fetch_resultsshared helper for response parsing and paginationtruncate_columnsinfab_util.pyfor terminal-width-aware column sizing (reusable by other commands)Files added
src/fabric_cli/client/fab_api_catalog.py— API client (search()function)src/fabric_cli/commands/find/__init__.py— Package initsrc/fabric_cli/commands/find/fab_find.py— Command logicsrc/fabric_cli/commands/find/type_supported.yaml— Supported/unsupported item typessrc/fabric_cli/errors/find.py—FindErrorsclasssrc/fabric_cli/parsers/fab_find_parser.py— Argument parserdocs/commands/find.md— Command documentationtests/test_commands/test_find.py— 15 e2e VCR teststests/test_commands/recordings/test_commands/test_find/*.yaml— VCR cassettestests/test_commands/api_processors/catalog_search_api_processor.py— Cassette processor for catalog search responsesFiles modified
src/fabric_cli/core/fab_parser_setup.py— Register find parsersrc/fabric_cli/errors/__init__.py— RegisterFinderror classsrc/fabric_cli/utils/fab_util.py— Addtruncate_columns(),!=regex support inget_dict_from_paramstests/test_commands/commands_parser.py— Register find parser + Windows PromptSession fix (scoped with try/finally)tests/test_commands/api_processors/api_processor_handler.py— RegisterCatalogSearchAPIProcessorpyproject.toml— Addtype_supported.yamlto package-dataMANIFEST.in— Addtype_supported.yamlto source distributionNotes
Dataflow)ReportCatalog.Read.Allscope