-
Notifications
You must be signed in to change notification settings - Fork 272
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
Metadata API: Accept X.Y spec_version #1796
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -431,16 +431,17 @@ def __init__( | |
expires: datetime, | ||
unrecognized_fields: Optional[Mapping[str, Any]] = None, | ||
): | ||
# Accept semver (X.Y.Z) but also X.Y for legacy compatibility | ||
spec_list = spec_version.split(".") | ||
if ( | ||
len(spec_list) != 3 | ||
or not all(el.isdigit() for el in spec_list) | ||
or spec_list[0] != SPECIFICATION_VERSION[0] | ||
if len(spec_list) not in [2, 3] or not all( | ||
el.isdigit() for el in spec_list | ||
Comment on lines
+436
to
+437
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a weird construct but black wants to lay it out this way -- I'll take suggestions to make it clearer though There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't have a better suggestion as well, but it's not so bad. |
||
): | ||
raise ValueError( | ||
f"Unsupported spec_version, got {spec_list}, " | ||
f"supported {'.'.join(SPECIFICATION_VERSION)}" | ||
) | ||
raise ValueError(f"Failed to parse spec_version {spec_version}") | ||
|
||
# major version must match | ||
if spec_list[0] != SPECIFICATION_VERSION[0]: | ||
raise ValueError(f"Unsupported spec_version {spec_version}") | ||
Comment on lines
+442
to
+443
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, finally, we don't want to log if there are differences in minor versions? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could do a debug log I suppose... but realistically a large portion of metadata that is deserialized is likely to not match exactly (think updated clients loading older targets metadata that was created with lower spec_version). |
||
|
||
self.spec_version = spec_version | ||
self.expires = expires | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. The data can even be valid, but because of the
_type
, it will fail...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah -- one of those cases where parsing exception messages might have helped... but I'm still not willing to do that amount of work