Skip to content
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

feat: decode future schema versions without throwing #213

Merged
merged 1 commit into from
Aug 19, 2024

Conversation

EvanHahn
Copy link
Contributor

We can now decode future schema versions without throwing. For example, if some future version encodes Observation_2, we can decode it as an Observation_1.

Closes #168.

We can now decode future schema versions without throwing. For example,
if some future version encodes `Observation_2`, we can decode it as an
`Observation_1`.

Closes [#168].

[#168]: https://github.com/digidem/mapeo-schema/issues/168
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "es2019",
"lib": ["es2020"],
"lib": ["es2022"],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Necessary to use Object.hasOwn. Only affects type checking.

@@ -14,12 +20,13 @@ export class ExhaustivenessError extends Error {

/**
* Get the name of the type, e.g. `Observation_5` for schemaName `observation`
* and schemaVersion `1`
* and schemaVersion `5`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change isn't strictly related but I believe it's a typo.

'',
...versionsLines,
'',
...knownVersionsLines,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

knownVersionsLines is no longer used so we can remove it, and all its dependencies.

@EvanHahn EvanHahn marked this pull request as ready for review August 14, 2024 22:09
@EvanHahn EvanHahn requested a review from tomasciccola August 14, 2024 22:10
@tomasciccola
Copy link
Contributor

if some future version encodes Observation_2, we can decode it as an Observation_1.

Is this actually reasoned like this? shouldn't we be able to decode Observation_2 as Observation_2 but with just newer fields ignored?
This is just a semantics question though...

@EvanHahn
Copy link
Contributor Author

Maybe more accurate: we can decode future schema versions, even if we don't know about them yet. As you said, we won't be able to decode newer fields, but that's just how Protobuf works.

@EvanHahn EvanHahn merged commit eeac6a2 into main Aug 19, 2024
6 checks passed
@EvanHahn EvanHahn deleted the decode-future-schema-versions-without-throwing branch August 19, 2024 22:15
@gmaclennan
Copy link
Member

Post-merge review: All looks good! As a non-urgent (and post-mvp) follow-up, maybe we can drop the schema version from being part of the protobuf name? I don't see a need for that now. But we can worry about this at a later time.

@tomasciccola
Copy link
Contributor

Post-merge review: All looks good! As a non-urgent (and post-mvp) follow-up, maybe we can drop the schema version from being part of the protobuf name? I don't see a need for that now. But we can worry about this at a later time.

Yeah, having the schema version as part of the protobuf is not useful but I think there was a reason for that? We should double check just in case

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.

Decode future schema versions without throwing
3 participants