-
Notifications
You must be signed in to change notification settings - Fork 30
feat(metadata): add CLI validation with URL-based schema loading #819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aaronsteers
wants to merge
4
commits into
devin/1760999875-add-metadata-models
Choose a base branch
from
vendor-metadata-yaml-and-add-cli
base: devin/1760999875-add-metadata-models
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat(metadata): add CLI validation with URL-based schema loading #819
aaronsteers
wants to merge
4
commits into
devin/1760999875-add-metadata-models
from
vendor-metadata-yaml-and-add-cli
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Vendor metadata schema YAML files from monorepo into CDK resources directory - Include fixes for SecretStore required fields and ConnectorBreakingChanges const usage - Add validate_metadata_file() function with Pydantic validation - Add 'airbyte-cdk metadata validate' CLI command with JSON and text output - Update generation script to use vendored YAML files instead of cloning from GitHub - Regenerate metadata_schema.json with fixed YAML files - Reorganize connector_metadata module into package structure This makes the CDK self-contained for metadata validation and removes dependency on the monorepo for schema files. Co-Authored-By: AJ Steers <aj@airbyte.io>
Original prompt from AJ Steers |
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
👋 Greetings, Airbyte Team Member!Here are some helpful tips and reminders for your convenience. Testing This CDK VersionYou can test this version of the CDK using the following: # Run the CLI from this branch:
uvx 'git+https://github.com/airbytehq/airbyte-python-cdk.git@vendor-metadata-yaml-and-add-cli#egg=airbyte-python-cdk[dev]' --help
# Update a connector to use the CDK from this branch ref:
cd airbyte-integrations/connectors/source-example
poe use-cdk-branch vendor-metadata-yaml-and-add-cliHelpful ResourcesPR Slash CommandsAirbyte Maintainers can execute the following slash commands on your PR:
|
Mirror the change from the monorepo PR to keep schemas in sync. The previous required fields (name, secretStore) were invalid and pointed to non-existent properties, meaning the generated Pydantic models effectively treated all fields as optional. Making both type and alias explicitly optional maintains backward compatibility with existing behavior. All 304 connectors with secretStore entries already include both type and alias fields, so this change is purely for backward compatibility. Co-Authored-By: AJ Steers <aj@airbyte.io>
Replace vendored YAML schema files with URL-based schema loading from the monorepo. This removes the dependency on vendoring schemas and allows the CDK to fetch the latest schema from a canonical source. Changes: - Remove vendored YAML files from airbyte_cdk/models/connector_metadata/resources/ - Remove bin/generate_connector_metadata_files.py schema generation script - Add get_metadata_schema() utility function to fetch schema from URL or file path - Refactor validate_metadata_file() to use JSON schema validation via jsonschema library - Add --schema flag to CLI for custom schema path/URL (defaults to monorepo URL) - Add comprehensive unit tests with local schema (no network dependency) - Add TODO comment to update URL to master branch after associated PR merges The default schema URL points to a specific commit in the monorepo: https://raw.githubusercontent.com/airbytehq/airbyte/61048d88732df93c50bd3da490de8d3cc1aa66b0/airbyte-ci/connectors/metadata_service/lib/metadata_service/models/generated/ConnectorMetadataDefinitionV0.json This will be updated to use the master branch URL after the associated PR merges. Co-Authored-By: AJ Steers <aj@airbyte.io>
Add explicit type casts to json.loads() return values to satisfy MyPy's no-any-return check. The json.loads() function returns Any, but we know the schema should be a dict[str, Any], so we use cast() to inform the type checker. Co-Authored-By: AJ Steers <aj@airbyte.io>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR refactors the metadata validation system to use URL-based schema loading instead of vendoring YAML schema files. The changes enable the CDK to fetch the canonical metadata schema directly from the monorepo, eliminating the need to maintain duplicate schema files.
Key changes:
airbyte_cdk/models/connector_metadata/resources/bin/generate_connector_metadata_files.py)get_metadata_schema()function that loads JSON schema from URL or file pathvalidate_metadata_file()to use JSON schema validation (viajsonschemalibrary)airbyte-cdk metadata validate --file <path> [--schema <url|path>] [--format json|text]connector_metadata.py→connector_metadata/metadata_file.py(maintains backward compatibility via__init__.py)Schema URL: Currently pinned to commit
61048d88...in the monorepo with a TODO to update to master branch after the associated monorepo PR merges.Review & Testing Checklist for Human
airbyte-integrations/connectors/source-*/metadata.yaml)https://raw.githubusercontent.com/airbytehq/airbyte/61048d88.../ConnectorMetadataDefinitionV0.jsonreturns a valid JSON schemaairbyte_cdk.models.connector_metadatastill works after the module reorganizationTest Plan
Notes
jsonschemalibrary is already a dependency (version>=4.17.3,<5.0in pyproject.toml)Link to Devin run: https://app.devin.ai/sessions/0078df9742174c169753b2c4c4d247da
Requested by: AJ Steers (@aaronsteers)