fix: refuse importing/saving user configs newer than Agent or firmware - #3047
Merged
Conversation
Import from file now uses the same shouldUpgradeAgent guard as device load, and Save to keyboard rejects configs above firmwareBuiltUserconfig. Co-authored-by: Cursor <cursoragent@cursor.com>
Peek the version before full deserialize so a too-new file gets a clear error instead of the generic "Invalid configuration specified." message. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Case B was hitting "Invalid configuration specified" when agent-update protection was disabled, because parse ran before any firmware check. Peek the version and compare it to firmwareBuiltUserconfig first. Co-authored-by: Cursor <cursoragent@cursor.com>
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
shouldUpgradeAgentpolicy already used when loading from the device)userConfigVersion(firmwareBuiltUserconfig), with version numbers in the errorTest plan
A. Import of newer config than Agent is refused
userConfigVersion, e.g. 15.0.0).UserConfiguration.jsonand bumpuserConfigMinorVersion(or major) so the semantic version is newer than Agent’s built userconfig (e.g.15.1.0if Agent is15.0.0).The imported user configuration version (15.1.0) is too high for this Agent (supports up to 15.0.0). Please update Agent.— config is not applied.B. Import above firmware capability is refused
Use
--disable-agent-update-protectionso guard A does not block the import:userConfigVersion(device info / logs).--disable-agent-update-protection.The imported user configuration version (X.Y.Z) is too high for this firmware (supports up to A.B.C). Please update the firmware or use a compatible configuration.— notInvalid configuration specified.C. Regression — normal path still works
D. Unit tests
Confirm
isUserConfigVersionHigherThanFirmware/readUserConfigurationVersion*cases pass.