Skip to content

Conversation

@akijakya
Copy link
Member

@akijakya akijakya commented Jan 6, 2026

This PR adds validate command to dirctl to either validate a local json file, or the whole content of the directory with different settings. Latter is done in batches, a test I ran that validated 3214 records finished in 10:17 mins.

dirctl validate --help
Validate OASF record JSON against the OASF schema. The JSON can be provided
as a file path or piped from stdin (e.g., from dirctl pull).

You must specify either --url for API-based validation or --disable-api for
embedded schema validation.

Usage examples:

1. Validate a file using embedded schemas (no API calls):
   dirctl validate record.json --disable-api

2. Validate a file with API-based validation:
   dirctl validate record.json --url https://schema.oasf.outshift.com

3. Validate a file with non-strict mode (more permissive, only works with --url):
   dirctl validate record.json --url https://schema.oasf.outshift.com --disable-strict

4. Validate JSON piped from stdin:
   cat record.json | dirctl validate --disable-api

5. Validate a record pulled from directory:
   dirctl pull <cid> | dirctl validate --disable-api

Note: You must specify either --url (for API validation) or --disable-api
(for embedded schema validation).

Usage:
  dirctl validate [<file>] [flags]

Flags:
      --disable-api      Disable API-based validation (use embedded schemas instead, required if --url is not specified)
      --disable-strict   Disable strict validation mode (more permissive validation, only works with --url)
  -h, --help             help for validate
      --url string       OASF schema URL for API-based validation (required if --disable-api is not specified)

Closes #767

@akijakya akijakya self-assigned this Jan 6, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

The latest Buf updates on your PR. Results from workflow Buf CI / verify-proto (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed⏩ skipped⏩ skipped✅ passedJan 9, 2026, 3:43 PM

@github-actions github-actions bot added the size/M Denotes a PR that changes 200-999 lines label Jan 6, 2026
@akijakya akijakya changed the title feat: dirctl validate feat(cli): dirctl validate Jan 6, 2026
@akijakya akijakya force-pushed the feat/dirctl-validate branch from ba4767f to 08cbe01 Compare January 6, 2026 14:31
@ramizpolic
Copy link
Member

ramizpolic commented Jan 7, 2026

We should reconsider flag usage, for example:

  • default case, no flags -> runs embedded schema validation
  • --api -> runs api-based validation
  • --strict -> runs api-based validation in strict mode

i think following default + enable approach is more intuitive than enforcing certain checks which need to be explicitly disabled

@ramizpolic
Copy link
Member

i dont think we need to have -all to run validation agianst the server, this will quickly exhaust the API rate limiting. this should really be a local-only API (which can be fed by other commands)

@akijakya
Copy link
Member Author

akijakya commented Jan 7, 2026

We should reconsider flag usage, for example:

  • default case, no flags -> runs embedded schema validation
  • --api -> runs api-based validation
  • --strict -> runs api-based validation in strict mode

i think following default + enable approach is more intuitive than enforcing certain checks which need to be explicitly disabled

These flags are mirroring the available settings for the directory:
DIRECTORY_SERVER_OASF_API_VALIDATION_SCHEMA_URL
DIRECTORY_SERVER_OASF_API_VALIDATION_DISABLE
DIRECTORY_SERVER_OASF_API_VALIDATION_STRICT_MODE

And the default validation mode is the API validation, that is why if neither of these settings are provided, both dir and this command returns an error that it needs an OASF URL, or the API validator to be disabled.

@akijakya akijakya force-pushed the feat/e2e-test-validation-cases branch 2 times, most recently from 6a832f8 to 78db38d Compare January 7, 2026 16:04
@akijakya akijakya force-pushed the feat/dirctl-validate branch from 08cbe01 to 2ca5f1e Compare January 7, 2026 16:08
@github-actions github-actions bot added size/L Denotes a PR that changes 1000-1999 lines and removed size/M Denotes a PR that changes 200-999 lines labels Jan 7, 2026
@akijakya
Copy link
Member Author

akijakya commented Jan 7, 2026

i dont think we need to have -all to run validation agianst the server, this will quickly exhaust the API rate limiting. this should really be a local-only API (which can be fed by other commands)

I agree that it has its limits if we are talking about a directory instance with hundreds of thousands of records... my goal with --all was to offer an easy way to validate a directory node in these early days when the OASF validator is also improving, so it might catch additional errors after an update, it might also be useful in other cases like before joining a node to the network, or accidentally changing the validation settings of a node and to make sure no invalid records were pushed in the meantime?

Another idea could be for the validate command to also accept a cid from the directory (not just a local file), which could then be scripted to check multiple cids from a directory instance if the user really wants to validate more than one record at a time, wdyt?

Or instead of a path, it could expect the json data directly, so it could be piped into it either from a local file, or the output of a dirctl pull command.

Base automatically changed from feat/e2e-test-validation-cases to main January 7, 2026 19:21
@akijakya akijakya force-pushed the feat/dirctl-validate branch from 2ca5f1e to 4948b0b Compare January 7, 2026 19:21
@akijakya akijakya marked this pull request as ready for review January 7, 2026 19:22
@akijakya akijakya requested a review from a team as a code owner January 7, 2026 19:22
@akijakya akijakya force-pushed the feat/dirctl-validate branch from 4948b0b to 67e6b82 Compare January 8, 2026 09:05
@github-actions github-actions bot added size/M Denotes a PR that changes 200-999 lines and removed size/L Denotes a PR that changes 1000-1999 lines labels Jan 8, 2026
@akijakya
Copy link
Member Author

akijakya commented Jan 9, 2026

@ramizpolic I removed the -all flag, but now the command can accept stdin as input so the result of a dirctl pull <cid> --output json can be piped into it. Also added tests with files for different validation scenarios.

@akijakya akijakya force-pushed the feat/dirctl-validate branch from 42417b5 to c998664 Compare January 9, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 200-999 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: dirctl validate for client-side record validation

3 participants