Skip to content

Feat: Configurable Discovery, Discovery libraries, and Consistent Error Codes - #18

Merged
ClassicMMT merged 18 commits into
mainfrom
add-configurable-discovery
Aug 12, 2026
Merged

Feat: Configurable Discovery, Discovery libraries, and Consistent Error Codes#18
ClassicMMT merged 18 commits into
mainfrom
add-configurable-discovery

Conversation

@ClassicMMT

@ClassicMMT ClassicMMT commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Added

  • Configurable discovery support.
  • Discovery configuration management: list, view, create, update, delete, validate, and status.
  • Discovery configuration library management: list, view, create, update, delete, validate, and status.
  • Start schema discovery or file discovery from a saved discovery configuration.
  • Download the discovery configuration that a run used.
  • Validation status for rulesets and ruleset libraries.
  • Safe data preview in the machine-readable output of schema discovery results and file discovery reports.
  • A command to start file data discovery.
  • A size limit for immediate validation.
  • An exit code for a declined confirmation, and an exit code for insufficient permission.
  • A line number and a column number for each validation error.
  • Support for the current DataMasque Python client release.

Changed

  • Ruleset library validation exits with an error code when the library is invalid.
  • Server and network failures give a message and an exit code, not a traceback.
  • File failures name the file.
  • A declined confirmation is no longer reported as a failure.
  • A run start or a run retry returns only the run identifier in machine-readable output.

Fixed

  • Ruleset validation reported an invalid ruleset as valid.
  • Ruleset generation, connection password updates, and the deprecated import command.

@ClassicMMT

ClassicMMT commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Requires dm-python SDP PR and dm-python configurable discovery PR to be merged and dm-python==1.1.8 published on PyPI.

Note to self: once dm-python==1.1.8 is published, need to update uv.lock.

@ClassicMMT
ClassicMMT force-pushed the add-configurable-discovery branch from 425fe39 to 43946b9 Compare July 17, 2026 04:14
@ClassicMMT ClassicMMT self-assigned this Jul 19, 2026
@ClassicMMT ClassicMMT changed the title Add configurable discovery Feat: Add configurable discovery Jul 19, 2026
@ClassicMMT
ClassicMMT force-pushed the add-configurable-discovery branch from 2ae01e0 to d69ef28 Compare July 19, 2026 23:37
@ClassicMMT
ClassicMMT requested review from kanewilliams and kw-datamasque and removed request for kanewilliams July 20, 2026 19:54
@ClassicMMT
ClassicMMT force-pushed the add-configurable-discovery branch 2 times, most recently from 5bb10f2 to 5acaca4 Compare July 30, 2026 21:43
@ClassicMMT
ClassicMMT marked this pull request as ready for review July 30, 2026 21:45
- Add support for datamasque-python 1.2.1
- Add a status command to rulesets, libraries, discover configs, and
  discover libraries
- Refuse YAML of 60 KiB+ in rulesets/discover configs validate
- Rework discover libraries for updated library model
- Fix rulesets generate and connections update --password
- Drop click dependency
- Update changelog
- Report server reason when library deletion is rejected
- Add validation to discover configs/libraries
- Abort on empty YAML directly
- Abort with not-found when a run has no discovery output
@ClassicMMT
ClassicMMT force-pushed the add-configurable-discovery branch from 67b4915 to fdb5852 Compare July 31, 2026 01:55
Comment thread tests/integration/test_discovery.py Outdated
Comment thread src/datamasque_cli/commands/discovery.py Outdated
Comment thread src/datamasque_cli/commands/discovery_configs.py Outdated
Comment thread tests/commands/test_rulesets.py Outdated
Comment thread tests/commands/test_rulesets.py Outdated
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread src/datamasque_cli/commands/discovery.py
Comment thread src/datamasque_cli/output.py Outdated
Comment thread src/datamasque_cli/output.py Outdated
@kw-datamasque

Copy link
Copy Markdown
Collaborator

I like this idea of abort_api_error() which shows DataMasque's errors instead letting Typer handle errors itself.

However it may be easy to forget to add it in specific CLI commands - claude has found a few above. Preferably we would use these new abort_...() functions consistently across all the commands.

Could we create a top-level safety net, does something like the following work? (claude)

  def main() -> None:
      try:
          app()
      except DataMasqueApiError as exc:
          abort_api_error("Request failed", exc)
      except DataMasqueTransportError as exc:
          abort(str(exc), code=ErrorCode.TRANSPORT_ERROR)

Apart from consistently using abort_...() family and the UTF-8 issue above, most of the other comments are minor and this will be a good addition to the DataMasque CLI

- improve naming
- refactor some test functions
- replace raise errors with abort_api_error
- reuse helpers to create configs and libraries in the integration tests
- show a proper error when a run has no file report
- name the sync-validation limit and its guard function accurately
- divide the discovery integration tests into two files
- read/write every file in utf-8
- add exit code 10 when a confirmation prompt is declined
- assert a specific exit code in every test
- declare pydantic rather than rely on dm-python
- bump the version to 1.5.0
- also merge abort_api_errors into one
@ClassicMMT

Copy link
Copy Markdown
Contributor Author

@kw-datamasque Thanks for your review!

The suggestions were great and I've implemented all of them and some more.

- Report the server reason when ruleset validation fails

@kw-datamasque kw-datamasque left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I roleplayed a tester and had Claude test the modified CLI surface to see if it received reasonable outputs.

It found 6 of the 14 comments below (2 pre-existing), marked with (Claude) followed by Input, Expected, Reason, Suggestion for reproducibility.

I've placed Suggestions to most comments hopefully these are easy fixes. The other comments are mostly tidy ups.

Comment thread src/datamasque_cli/commands/discovery.py
Comment thread src/datamasque_cli/commands/discovery.py Outdated
Comment thread src/datamasque_cli/commands/discovery.py Outdated
Comment thread src/datamasque_cli/commands/discovery.py
Comment thread src/datamasque_cli/commands/discovery_configs.py Outdated
Comment thread tests/integration/test_discovery_configs.py Outdated
Comment thread src/datamasque_cli/commands/ruleset_libraries.py Outdated
Comment thread src/datamasque_cli/commands/discovery.py Outdated
Comment thread src/datamasque_cli/main.py
Comment thread src/datamasque_cli/main.py Outdated
@ClassicMMT
ClassicMMT force-pushed the add-configurable-discovery branch from b2e8b54 to 54cffff Compare August 10, 2026 03:39
- remove "status": "queued" field
- fix 400 error return message
- replace asserts with explicit abort calls
- stop dm run ... returning 4 on successful command run
  - returns 3 if incorrect name, otherwise 0
- resolve every error code from a single HTTP-status table
- tests added and modified
@ClassicMMT
ClassicMMT force-pushed the add-configurable-discovery branch from 54cffff to 58526bf Compare August 10, 2026 03:43

@kw-datamasque kw-datamasque left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Almost there- Two small asks before merge:

  1. Could you please add a PR description as a best practice? Doesn't need to be super polished.

  2. Could the title reflect the full scope too? Something like "feat: configurable discovery, discovery libraries, consistent error codes"

Comment thread src/datamasque_cli/main.py Outdated
Comment thread src/datamasque_cli/errors.py Outdated
Comment thread src/datamasque_cli/commands/rulesets.py Outdated
Comment thread tests/integration/test_discovery.py
@ClassicMMT ClassicMMT changed the title Feat: Add configurable discovery Feat: Configurable Discovery, Discovery libraries, and Consistent Error Codes Aug 11, 2026
@ClassicMMT
ClassicMMT force-pushed the add-configurable-discovery branch from 4ab10aa to 27b241b Compare August 11, 2026 22:42
@ClassicMMT
ClassicMMT force-pushed the add-configurable-discovery branch from 27b241b to 69ea485 Compare August 11, 2026 23:15
@ClassicMMT
ClassicMMT merged commit c795bc1 into main Aug 12, 2026
5 checks passed
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