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

fix: make extensions that don't use project templates backwards-compatible #4060

Merged
merged 2 commits into from
Jan 10, 2025

Conversation

anchpop
Copy link
Contributor

@anchpop anchpop commented Jan 10, 2025

Description

There was recently an addition of pub project_templates: Option<HashMap<String, ExtensionProjectTemplate>> to the struct ExtensionManifest.

This is somewhat problematic on its own because ExtensionManifest has #[serde(deny_unknown_fields)]. So any extension that has this field in its manifest won’t be compatible with any version of DFX that was released prior to this field being added.

This lack of backwards-compatibility might be desirable for extensions that declare project templates (since old versions of DFX wouldn't support the extension's whole feature set). But extensions that don't declare project templates should probably be backwards compatible.

So let's tell serde to be tolerant to the field being omitted using #[serde(default)], and skip serializing it if an extension manifest doesn't declare project templates. This will ensure that projects who generate their manifests programmatically (like the NNS and SNS extensions) don't accidentally lose backwards compatibility.

Checklist:

  • The title of this PR complies with Conventional Commits.
  • I have edited the CHANGELOG accordingly. (not necessary I think)
  • I have made corresponding changes to the documentation. (not necessary I think)

@anchpop anchpop requested a review from a team as a code owner January 10, 2025 18:09
@anchpop anchpop force-pushed the @anchpop/backwards-compatible-project-templates branch from fdcd1c7 to c5f8c30 Compare January 10, 2025 18:17
@anchpop anchpop enabled auto-merge (squash) January 10, 2025 18:36
@anchpop anchpop merged commit 097a49a into master Jan 10, 2025
297 checks passed
@anchpop anchpop deleted the @anchpop/backwards-compatible-project-templates branch January 10, 2025 19:17
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.

2 participants