Skip to content

Fix export validation of freshly read config bytes - #200

Merged
mblauberg merged 1 commit into
mainfrom
lane/export-check
Nov 4, 2026
Merged

mblauberg merged 1 commit into
mainfrom
lane/export-check

Conversation

@mblauberg

Copy link
Copy Markdown
Owner

Summary

Export Settings now validates the exact bytes it reads before writing the destination, using the same validation and field error formatting as config loading.

Previously, loading {"dpi":800} and then overwriting the file with {"dpi":999999} without reloading let export succeed with an invalid file. Export now returns the DPI range error and leaves the destination absent.

How checked

  • Added exportRefusesInvalidBytesWrittenSinceTheLastLoad using temporary Sandbox directories.
  • Before the fix, swift test --filter ConfigTransferTests.exportRefusesInvalidBytesWrittenSinceTheLastLoad reproduced both failures: export returned nil and created the invalid destination.
  • After the fix, swift build && swift test --filter ConfigTransferTests passed: 10 tests.
  • git diff --check passed.
  • No live config touched and no daemon, menu, or Settings launched.

Footprint

No daemon or menu app changes. Validation runs only when exporting.

Docs

No update needed: docs/configuration.md already guarantees that a config that does not load is not exported. This fixes implementation of that guarantee.

Agent evidence
  • Base: 63b7b9c; commit: 1a2f855.
  • Reviewed ConfigStore.reloadConfig(), flush(), ConfigCheck validation/error formatting, export callers, and the existing Sandbox fixture.
  • Changes limited to Sources/PureMouseAppSupport/ConfigTransfer.swift and Tests/PureMouseAppSupportTests/ConfigTransferTests.swift (17 added lines).
  • Validation operates on the same immutable Data subsequently written atomically, without rereading the source.
  • Kept the existing cached-error guard and export error prefix.
  • Local compiler: Apple Swift 6.4.2. Swift 6.3 execution remains for CI; no new APIs or closure patterns.
  • Existing warnings from unrelated code appeared during initial test compilation; targeted checks passed after the fix.
  • Only targeted tests run locally, as requested.

@mblauberg mblauberg added the bug Something isn't working label Nov 4, 2026 — with ChatGPT Codex Connector
@mblauberg
mblauberg merged commit ccc4316 into main Nov 4, 2026
2 checks passed
@mblauberg
mblauberg deleted the lane/export-check branch November 4, 2026 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant