Skip to content

fix(factory_reset): adapt result parsing to omnect-os-init JSON contract - #207

Open
JanZachmann wants to merge 3 commits into
omnect:mainfrom
JanZachmann:jz-2026-07-28-factory-reset-json-contract
Open

fix(factory_reset): adapt result parsing to omnect-os-init JSON contract#207
JanZachmann wants to merge 3 commits into
omnect:mainfrom
JanZachmann:jz-2026-07-28-factory-reset-json-contract

Conversation

@JanZachmann

@JanZachmann JanZachmann commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Closes #205

Summary

Adapt the factory-reset result parsing to the JSON that omnect-os-init writes to /run/omnect-device-service/omnect-os-initramfs.json:

  • read key factory_reset (was factory-reset)
  • new status 4 (warning: reset ok, but a partition needed a second mkfs)
  • error, context and paths are optional with defaults
  • a future unknown status code parses as Unknown (reported as u32::MAX) instead of failing ODS startup; the raw result is logged as warning
  • status is u32 to match the omnect-os-init serialization (serialize_u32), so even a code > 255 cannot break startup
  • status variants renamed to the omnect-os-init names (wire format unchanged; the old names described the codes wrongly in logs)
  • report data_wiped: on error it distinguishes a safe abort from a failure after data was already wiped
  • report error and context as null instead of omitting them: twin reports are merge patches, so an omitted key would keep the value of a previous result
  • feature version bumped 3 -> 4 because the reported result shape changed
  • testfiles updated to the real omnect-os-init output shape; result fields documented in the README

Reason

The parser and the omnect-os-init contract did not match, so the factory-reset result never reached the twin. After fixing only the key, a status: 4 or a missing error/paths would have failed FactoryReset::new() and with it ODS startup. See #205 for the full mismatch table.

Follow-up

omnect-ui deserializes the published result with a required error field and status 0..=3 only, so it cannot parse the new shape (including the normal successful reset): omnect/omnect-ui#125

omnect-os-init writes the factory-reset result with key "factory_reset",
status codes 0..=4 and optional error/context/paths fields. The old
parser expected key "factory-reset" and required error/paths, so the
result was never reported.

- read key "factory_reset"
- add status 4 (warning: reset ok, but a partition needed a second mkfs)
- error, context and paths are optional with defaults
- a future unknown status code parses as Unknown instead of failing ODS
  startup; the raw result is logged
- status is u32 to match the omnect-os-init serialization
- bump feature version to 4 because the reported result shape changed

Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
Twin reports are merge patches: a key omitted from a new result keeps
the value of a previous one. Report error and context as null instead
of omitting them, so a successful reset clears the error of an earlier
failed one.

- report data_wiped: on error it distinguishes a safe abort from a
  failure after data was already wiped
- rename status variants to the omnect-os-init names (wire format
  unchanged; the old names described the codes wrongly in logs)
- align warning testfile with real omnect-os-init output (warning
  carries a context note, no error)
- test explicit "factory_reset": null and that FactoryReset::new()
  succeeds with an unknown status code
- document the result fields in the README

Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
@JanZachmann
JanZachmann requested a review from JoergZeidler July 28, 2026 11:59
@JanZachmann

Copy link
Copy Markdown
Contributor Author

FYI @mlilien

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.

Adapt factory-reset result parsing to the omnect-os-init JSON contract

1 participant