Skip to content

fix: refuse importing/saving user configs newer than Agent or firmware - #3047

Merged
mondalaci merged 4 commits into
masterfrom
fix/2784-block-newer-userconfig
Aug 8, 2026
Merged

fix: refuse importing/saving user configs newer than Agent or firmware#3047
mondalaci merged 4 commits into
masterfrom
fix/2784-block-newer-userconfig

Conversation

@mondalaci

@mondalaci mondalaci commented Aug 8, 2026

Copy link
Copy Markdown
Member

Summary

Test plan

A. Import of newer config than Agent is refused

  1. Build/run this Agent (current userConfigVersion, e.g. 15.0.0).
  2. Take a UserConfiguration.json and bump userConfigMinorVersion (or major) so the semantic version is newer than Agent’s built userconfig (e.g. 15.1.0 if Agent is 15.0.0).
  3. Device → Configuration → Import from file.
  4. Expected: Error like: 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.
  5. Confirm a same-or-older version JSON still imports normally.

B. Import above firmware capability is refused

Use --disable-agent-update-protection so guard A does not block the import:

  1. Note the connected firmware’s userConfigVersion (device info / logs).
  2. Start Agent with --disable-agent-update-protection.
  3. Import a configuration whose version is strictly greater than that firmware userconfig version (and that Agent can otherwise peek).
  4. Expected: Error like: 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. — not Invalid configuration specified.
  5. Optional: if a too-new config somehow gets into memory, Save to keyboard still shows the same firmware version comparison.

C. Regression — normal path still works

  1. With matching Agent + firmware + config versions (typical daily use), import a same-version export and Save to keyboard.
  2. Expected: Import and save succeed as before.
  3. Optional: load config from device that is newer than Agent → still routed to Update Agent (unchanged device-load path).

D. Unit tests

cd packages/uhk-common && npm test

Confirm isUserConfigVersionHigherThanFirmware / readUserConfigurationVersion* cases pass.

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>
mondalaci and others added 3 commits August 8, 2026 19:48
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>
@mondalaci
mondalaci merged commit d7d0093 into master Aug 8, 2026
6 checks passed
@mondalaci
mondalaci deleted the fix/2784-block-newer-userconfig branch August 8, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[low priority] Userconfig versions - Agent allows flashing higher config versions.

1 participant