fix(harbor): validate schema_version in adapt and stamp it in export - #584
Open
ayushnangia wants to merge 3 commits into
Open
fix(harbor): validate schema_version in adapt and stamp it in export#584ayushnangia wants to merge 3 commits into
ayushnangia wants to merge 3 commits into
Conversation
The exported task.toml carries a top-level 'version' key, but the adapter parses 'schema_version' — so the stamped version was invisible to validation and a task declaring any unknown schema_version adapted silently with wrong semantics. Define HARBOR_SCHEMA_VERSION, fail adaptation loudly for unsupported values, and stamp the field in export so round-tripped tasks validate against the same contract.
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
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
The Harbor interop's own fidelity promise has a hole in it:
export()writes a top-levelversion = "1.0"into the generatedtask.toml, but the adapter parses a field namedschema_version— so the stamped version is invisible to validation, and a task declaring any unknownschema_versionadapts silently with whatever semantics this build happens to implement. A task authored against a future or foreign schema should fail adaptation loudly (the same contract as the other invalid-task paths), not adapt wrong.Changes
hud/integrations/harbor/adapt.py: newHARBOR_SCHEMA_VERSION = "1.0";adapt()raisesValueError("declares unsupported Harbor schema ...") when a task'sschema_versionis present and differs. Absent stays accepted (unversioned tasks are the historical export shape).hud/integrations/harbor/export.py: generatedtask.tomlnow stampsschema_version = "1.0"alongside the existingversionkey, so round-tripped tasks validate against the exact contract they were written by.Validation
hud/integrations/harbor/tests/test_contract.py: unknown schema fails loudly · supported schema adapts · absent schema still adapts.pytest hud/integrations/harbor/tests→ 65 passed, 0 failed; full suite (hud/tests+ capabilities + patches) → 136 passed.Scope note
Public surface untouched (
__all__stays["adapt", "export"]per the contract test). This is the schema half of version pinning; if maintainers want task-side pinning (task.toml requiring a HUD version range), that's a follow-up feature and I have the spec sketched.Note
Low Risk
Localized Harbor integration validation and export metadata; backward compatible for tasks without
schema_version.Overview
Closes a Harbor interop gap where
export()only wroteversion = "1.0"whileadapt()readsschema_version, so exported tasks were unversioned for adaptation and foreign schemas could adapt silently.adapt()now enforcesHARBOR_SCHEMA_VERSION("1.0"): iftask.tomlsets a differentschema_version, adaptation raisesValueErrorwith an explicit unsupported-schema message. Missingschema_versionstill adapts for legacy/unversioned tasks.export()stampsschema_version = "1.0"in generatedtask.toml(alongsideversion) so HUD-exported Harbor folders round-trip under the same contract.Contract tests cover unknown schema (fail), supported schema (adapt), and absent schema (still adapt).
Reviewed by Cursor Bugbot for commit df31867. Bugbot is set up for automated code reviews on this repo. Configure here.