fix: sync the settings the environment declares, not the base ones - #748
Open
raymondk wants to merge 1 commit into
Open
fix: sync the settings the environment declares, not the base ones#748raymondk wants to merge 1 commit into
raymondk wants to merge 1 commit into
Conversation
`icp canister settings sync` resolved its canister through `Context::get_canister_and_path_for_env`, which returned the record from `Project::canisters` and used the environment only to check membership. Consolidation layers an environment's `settings:` overrides onto a *clone* of that base record, so the base one still carries the pre-override settings: a setting declared only under `environments:` was never synced, and the command reported success having changed nothing. That bites hardest in a workspace, because folding a vendored member's own `environments:` config into the root's same-named environments is how a member keeps its standalone settings — so a service configuring itself per environment had those settings ignored for every canister it owns. `icp deploy` already read the environment's record for its settings phases (`env.get_canister_info`), and only used the base record to build, so the two commands disagreed about the same canister in the same environment. Return the environment's record instead. It is a strict refinement of the base one, and the two other callers consult build and sync steps, which are not environment-overridable. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes environment-specific settings synchronization by returning the selected environment’s resolved canister configuration.
Changes:
- Resolves canisters from the environment map while preserving existing errors.
- Adds unit and integration regression tests.
- Documents the fix in the changelog.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
CHANGELOG.md |
Records the settings-sync fix. |
crates/icp/src/context/mod.rs |
Returns environment-resolved canister settings. |
crates/icp/src/context/tests.rs |
Tests overrides and omitted canisters. |
crates/icp-cli/tests/canister_settings_tests.rs |
Verifies sync restores an environment variable. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Problem
icp canister settings syncresolves its canister throughContext::get_canister_and_path_for_env. Despite the name, that accessor returned the record fromProject::canisters— the base, pre-override map — and used the environment only for a membership check:Consolidation layers an environment's
settings:overrides onto a clone of the base record (build_environment_canisters), so the base one still carries the pre-override settings. A setting declared only underenvironments:was therefore never synced — and becausesync_settingstreatsNoneas "leave alone", the command exited 0 having changed nothing, with no warning.This bites hardest in a workspace with
dependencies:. Folding a vendored member's ownenvironments:config into the root's same-named environments is how a member keeps the settings it would have standalone, so a service that configures itself per environment had those settings silently ignored for every canister it owns.icp deploydid not have the bug: it uses the base record only to build, and switches to the environment's record for its settings phases (env.get_canister_info). So the two commands disagreed about the same canister in the same environment.Fix
Return the environment's record. It is a strict refinement of the base one, and the two other callers (
commands/build.rs,commands/sync.rs) consult build and sync steps, which are not environment-overridable.Tests
canister_settings_sync_applies_environment_override— an integration test that deploys, removes the variable on-canister, and requiressettings syncto restore it from the environment override. Without the fix it fails with the variable still absent.cargo test -p icp --lib,--test canister_settings_tests,--test dependency_testsand--test deploy_testspass, pluscargo fmtandcargo clippy --all-targets. The one failure locally isdeploy_cloud_engine::docker::test, which needs a Docker daemon I don't have running.Not covered here
settings syncstill never stampsPUBLIC_CANISTER_ID:*. Those are computed as bindings and written byset_binding_env_vars_many, which onlydeploycalls — so sync can neither add a missing dependency id nor correct a stale one. That is a separate gap.🤖 Generated with Claude Code