Repository navigation
fix(ios): refuse a device id that is not one where it would act: config load, token read, kill - #784
Merged
Merged
Conversation
…ig load, token read, kill
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
2 tasks done
pbertsch
added a commit
that referenced
this pull request
Nov 17, 2026
… load now requires (#788) ## Summary The Studio tests are green again. Since #784, `config.Load` refuses a `device.ios_device_id` that is not a simulator or device UDID. Four Studio tests still wrote or saved made-up ids (`ABC`, `SIM-UDID`, `X`, `IOS-1`), so they failed on `main`. The hosted Studio workflow does not run, so the failures did not show in CI. On `main`, `go test -race ./studio/...` failed in four tests: - `TestRandomProbeYAMLShapesAreEditedExactlyOrRefused`: "only 143 of 500 random files could be saved". The generator wrote `ios_device_id: ABC`, so those shapes no longer load. - `TestSaveWorkspaceSettingsKeepsEverythingElseInProbeYAML`: "invalid device.ios_device_id "SIM-UDID"". - `TestSaveWorkspaceSettingsRemovesClearedKeys`: saved `X`, and clearing it then failed because the file no longer loads. - `TestConcurrentSavesOfDifferentFieldsAllLand`: one of its fields was `IOS-1`. The fix is test data only: each of those ids is now a simulator UDID (a UUID). No production code changes, so there is no CHANGELOG entry. ## Test plan - [x] `go test -race -count=1 ./studio/...` with a stub `studio/frontend/dist/index.html`: ``` ok github.com/alphawavesystems/flutter-probe/studio 215.472s ok github.com/alphawavesystems/flutter-probe/studio/e2e 1.212s ``` No data race reported. - [x] The same four tests fail on `origin/main` without this change; reproduced on a clean checkout.
5 tasks done
pbertsch
added a commit
that referenced
this pull request
Nov 17, 2026
…789) ## Summary Follow-ups from the review of #784: every way to name an iOS device now follows the rule of `device.ios_device_id`, which must be a simulator UDID or a device UDID. - **`probe test --device`** for an iOS simulator or device must be a UDID (`validIOSDeviceFlag`). Until now it only had `config.ValidateDeviceSerial`'s character class, which allows `/` and `.`, while the same id shapes host paths (a simulator's data folder) and devicectl arguments. The check runs once the platform is known, so Android serials keep their rule. - **Studio's Settings** refuse to save an iOS device that is not a UDID, and write nothing; before, a value the CLI then refused to load could be saved. The check applies only when that field changed, so an old value doesn't block saving other fields (the config load reports it). - **Messages** point at `probe device list`, in the config load error, the `--device` error and Studio's error. - **Docs:** the missing period in the `ios_device_id` row of `advanced/configuration.md`; the `--device` row of `tools/cli-reference.md`; a sentence in `platform/ios.md`. Not covered: the parallel `--devices` list keeps its current check (each serial must be a connected device). It can follow in its own change. The Studio test values are the same as in #788, which fixes the Studio tests on `main`; this branch has the same edits, so the two merge cleanly in either order. ## Tests - `TestIOSDeviceFlagMustBeAUDID`: a simulator UDID, a 25-character and a 40-character device UDID pass. `../../x`, `/etc`, `iPhone.16`, a UUID with `/../x` and `abc` are refused, and the message names `--device` and `probe device list`. Android serials, including `ip:port`, pass. - `TestProbeTestChecksTheIOSDeviceFlag`: a source check that `probe test` calls it. - `TestSaveWorkspaceSettingsRefusesAnIOSDeviceIDThatIsNotAUDID`: four bad values are refused and not written; three good ones are saved. ## Mutation check Each mutant was applied, the tests were run, and the file was restored byte for byte. All 6 were killed. Two did not compile at first (an unused import) and were rewritten. | Mutant | Result | |---|---| | `probe test` does not call the check | killed | | any iOS id accepted | killed | | device UDIDs refused | killed | | Android held to the iOS rule | killed | | Studio saves any id | killed | | Studio refuses device UDIDs | killed | ## Test plan - [x] `go test ./internal/cli/ ./internal/config/` passes. - [x] `go test -race -count=1 ./studio/...` (stub `frontend/dist`): `studio` ok in 216 s, `studio/e2e` ok, no data race. - [x] `staticcheck` on `cli` and `config`. In `studio`, staticcheck reports one finding, S1011 in `replace_line_classify_test.go`; that file is already on `main` and this PR doesn't touch it. - [x] `GOOS=windows go vet ./internal/...`. - [x] No raw format characters.
Merged
6 tasks done
pbertsch
added a commit
that referenced
this pull request
Nov 17, 2026
…arer device messages (#791) ## Summary Follow-ups from the review of #789. **1. Studio can repair an old iOS device that is not a UDID.** Since #784, `config.Load` refuses a `device.ios_device_id` that is not a UDID, and Studio's Settings load went through it. So a `probe.yaml` written before that rule (`ios_device_id: iPhone 16`) could not be opened in Settings, and a save then failed with a misleading "probe.yaml changed on disk since the form was loaded". - `config.LoadForRepair(dir)` reads `probe.yaml` like `Load`, except that a non-UDID `ios_device_id` is kept and its error is returned on its own (`*config.IOSDeviceIDError`). Every other rule still fails it. Only an editor uses it; a run keeps `Load`, which still refuses. - `LoadWorkspaceSettings` uses it. It sets the new `iosDeviceIdProblem` field: the value, that it is not a UDID, the pointer to `probe device list`, and that a run refuses the file until it is fixed. The form shows that as text under the iOS field (`settings-ios-problem`; `textContent`, never markup). `models.ts` has the field. - Saving a UDID in its place repairs the file. Saving another field with the old value left as it is still lands: only a changed iOS device is held to the rule. - **The misleading message:** when the file on disk can't be read by the engine, there is nothing to compare with, so Save no longer reports a change on disk. The existing checks refuse with the real reason ("would not load", "not a map"). **2. Tests for the three survivors of the #789 review:** - the "only when changed" condition; - trimming before the rule; - the `probe device list` pointer in the `config.LoadFile` error. **3. A behavioural test instead of the source check.** The device choice of `probe test` is now one function, `pickLocalDevice`, with the device list passed in. `TestPickLocalDevice` drives it: the platform comes from the list, the iOS rule is checked once the platform is known, the preferences apply, the first device is used when none is named, and a run with no device fails. **4. The edge message.** With `defaults.platform: ios` and an Android serial that is not in the device list, the message now says the serial is not in the device list (see `probe device list`), and that for an iOS device it must be a UDID. It no longer says "invalid --device for an iOS device". Docs: `platform/ios.md` says an older value still opens in Studio's Settings so it can be replaced, and how an unlisted serial is reported. ## Tests - `studio/ios_device_repair_test.go`: - **show and repair:** the value is shown with the problem; saving a UDID makes `config.Load` pass, and the problem is gone; - **an unchanged bad value doesn't block another field**, and stays; - **a UDID with spaces around** is saved trimmed; - **an unreadable `probe.yaml`** is refused with "would not load", not "changed on disk", and the file is unchanged. - `internal/config/ios_device_id_test.go`: the `Load` error points at `probe device list`. `LoadForRepair` keeps the value and the other fields and reports the iOS error on its own, while still refusing an invalid `project.app`. - `internal/cli/ios_device_flag_test.go`: `TestPickLocalDevice`, 10 cases. It replaces #789's source check. ## Mutation check Each mutant was applied, the tests were run, and the file was restored byte for byte. All 10 were killed. One did not compile at first and was rewritten. | Mutant | Result | |---|---| | Studio loads strictly (`config.Load`) | killed | | no problem shown | killed | | disk compared even when unreadable | killed | | the rule holds an unchanged value | killed | | no trimming before the rule | killed | | platform not taken from the device list | killed | | iOS rule gone | killed | | not-in-the-list message gone | killed | | config error without the pointer | killed | | the repair load fails on the iOS id | killed | ## Test plan - [x] `go test ./internal/cli/ ./internal/config/` passes. - [x] `go test -race -count=1 ./studio/...` (stub `frontend/dist`): `studio` ok in 214 s, `studio/e2e` ok, no data race. - [x] `tsc --noEmit` in `studio/frontend` passes (with an existing `node_modules`; nothing installed, `package-lock.json` unchanged). - [x] `staticcheck` on `cli`, `config` and `studio`; its one finding is S1011, which is already on `main` and fixed by #790. - [x] `GOOS=windows go vet ./internal/...`. - [x] No raw format characters.
jay23606
added a commit
to jay23606/flutter-probe
that referenced
this pull request
Nov 17, 2026
…ig load, token read, kill (AlphaWaveSystems#784) ## Summary Follow-ups from the review of AlphaWaveSystems#780: a device id that is not one is now refused where it would act, not later. 1. **`device.ios_device_id` must be a UDID.** It becomes the iOS device serial (`internal/cli/test.go`), and a simulator id shapes host paths. Until now it was not validated: `config.ValidateDeviceSerial` allows `/` and `.`, and does not see this key. - `config.LoadFile` now refuses anything but a simulator UDID or a device UDID (`ios.ValidSimulatorUDID` / `ios.ValidDeviceUDID`), with a message that names the key and says where to find the id. - Breaking for a `probe.yaml` that put a device name there. As the `--device` serial, a name with a space already failed. 2. **`DeviceCtl.Terminate` no longer hides a failed process lookup.** It returned nil, meaning "not running", whenever `FindPID` failed, including for an id AlphaWaveSystems#780 refuses. So on a physical iPhone a kill could pass silently and a relaunch could start beside a running app. It now returns the lookup error, and `KillApp` prints `the app was not stopped: …` in one line. The error quotes the id with `%q`. 3. **`SimCtl.ReadToken` fails fast** for an id that is not a simulator UDID (a physical device's, or not an id), instead of polling for the whole timeout. 4. **The token paths are built in one place**, `SimCtl.tokenFileCandidates`: the app's container, every data container, then the legacy device-level file. With an id that is not a simulator UDID it returns no path at all, the legacy file included. It is testable on its own; that mutant survived in AlphaWaveSystems#780. 5. **CHANGELOG wording of AlphaWaveSystems#780, corrected:** - the device UDID is 8 hex digits, a dash and **exactly 16** hex digits (not "8-16"), or 40; - only the id's first 8 characters were used, so the reach was a `.json` file **one folder above** the temporary folder. Docs: `advanced/configuration.md` (the `ios_device_id` row) and `platform/ios.md` say the value must be a UDID. Their example is a valid UUID. ## Tests - `TestTokenFileCandidatesNeedASimulatorUDID`: no paths for a device UDID or any of AlphaWaveSystems#780's hostile ids. A simulator's list ends with the legacy file. - `TestReadTokenFailsFastForAnIDThatIsNotASimulator`: a hostile id, a device UDID and an empty id are each refused in under a second, with a 5 s timeout. - `TestTerminateReportsALookupFailure`: a refused id gives the lookup error, and the fake `xcrun` never runs. - `TestKillOnAPhysicalIPhoneWarnsWhenTheLookupFails`: the warning line is printed. - `TestIOSDeviceIDMustBeAUDID`: empty, a UUID, a 25-character and a 40-character device UDID load. `../../x`, `/etc`, `iPhone 16`, a UUID with `/../x` and `*` are refused with the key named. ## Mutation check Each mutant was applied, the tests were run, and the file was restored byte for byte. All 5 were killed. | Mutant | Result | |---|---| | `ReadToken` does not fail fast | killed | | the legacy fallback is built without a data path | killed | | `Terminate` hides the lookup failure | killed | | `KillApp` drops the warning | killed | | the config accepts any `ios_device_id` | killed | ## Test plan - [x] `go test ./internal/ios/ ./internal/config/ ./internal/runner/ ./internal/cli/` passes. - [x] `go vet` and `staticcheck` pass on the changed packages. - [x] No raw format characters in the changed files. - [x] Mutation check (table above).
jay23606
added a commit
to jay23606/flutter-probe
that referenced
this pull request
Nov 17, 2026
… load now requires (AlphaWaveSystems#788) ## Summary The Studio tests are green again. Since AlphaWaveSystems#784, `config.Load` refuses a `device.ios_device_id` that is not a simulator or device UDID. Four Studio tests still wrote or saved made-up ids (`ABC`, `SIM-UDID`, `X`, `IOS-1`), so they failed on `main`. The hosted Studio workflow does not run, so the failures did not show in CI. On `main`, `go test -race ./studio/...` failed in four tests: - `TestRandomProbeYAMLShapesAreEditedExactlyOrRefused`: "only 143 of 500 random files could be saved". The generator wrote `ios_device_id: ABC`, so those shapes no longer load. - `TestSaveWorkspaceSettingsKeepsEverythingElseInProbeYAML`: "invalid device.ios_device_id "SIM-UDID"". - `TestSaveWorkspaceSettingsRemovesClearedKeys`: saved `X`, and clearing it then failed because the file no longer loads. - `TestConcurrentSavesOfDifferentFieldsAllLand`: one of its fields was `IOS-1`. The fix is test data only: each of those ids is now a simulator UDID (a UUID). No production code changes, so there is no CHANGELOG entry. ## Test plan - [x] `go test -race -count=1 ./studio/...` with a stub `studio/frontend/dist/index.html`: ``` ok github.com/alphawavesystems/flutter-probe/studio 215.472s ok github.com/alphawavesystems/flutter-probe/studio/e2e 1.212s ``` No data race reported. - [x] The same four tests fail on `origin/main` without this change; reproduced on a clean checkout.
jay23606
added a commit
to jay23606/flutter-probe
that referenced
this pull request
Nov 17, 2026
…lphaWaveSystems#789) ## Summary Follow-ups from the review of AlphaWaveSystems#784: every way to name an iOS device now follows the rule of `device.ios_device_id`, which must be a simulator UDID or a device UDID. - **`probe test --device`** for an iOS simulator or device must be a UDID (`validIOSDeviceFlag`). Until now it only had `config.ValidateDeviceSerial`'s character class, which allows `/` and `.`, while the same id shapes host paths (a simulator's data folder) and devicectl arguments. The check runs once the platform is known, so Android serials keep their rule. - **Studio's Settings** refuse to save an iOS device that is not a UDID, and write nothing; before, a value the CLI then refused to load could be saved. The check applies only when that field changed, so an old value doesn't block saving other fields (the config load reports it). - **Messages** point at `probe device list`, in the config load error, the `--device` error and Studio's error. - **Docs:** the missing period in the `ios_device_id` row of `advanced/configuration.md`; the `--device` row of `tools/cli-reference.md`; a sentence in `platform/ios.md`. Not covered: the parallel `--devices` list keeps its current check (each serial must be a connected device). It can follow in its own change. The Studio test values are the same as in AlphaWaveSystems#788, which fixes the Studio tests on `main`; this branch has the same edits, so the two merge cleanly in either order. ## Tests - `TestIOSDeviceFlagMustBeAUDID`: a simulator UDID, a 25-character and a 40-character device UDID pass. `../../x`, `/etc`, `iPhone.16`, a UUID with `/../x` and `abc` are refused, and the message names `--device` and `probe device list`. Android serials, including `ip:port`, pass. - `TestProbeTestChecksTheIOSDeviceFlag`: a source check that `probe test` calls it. - `TestSaveWorkspaceSettingsRefusesAnIOSDeviceIDThatIsNotAUDID`: four bad values are refused and not written; three good ones are saved. ## Mutation check Each mutant was applied, the tests were run, and the file was restored byte for byte. All 6 were killed. Two did not compile at first (an unused import) and were rewritten. | Mutant | Result | |---|---| | `probe test` does not call the check | killed | | any iOS id accepted | killed | | device UDIDs refused | killed | | Android held to the iOS rule | killed | | Studio saves any id | killed | | Studio refuses device UDIDs | killed | ## Test plan - [x] `go test ./internal/cli/ ./internal/config/` passes. - [x] `go test -race -count=1 ./studio/...` (stub `frontend/dist`): `studio` ok in 216 s, `studio/e2e` ok, no data race. - [x] `staticcheck` on `cli` and `config`. In `studio`, staticcheck reports one finding, S1011 in `replace_line_classify_test.go`; that file is already on `main` and this PR doesn't touch it. - [x] `GOOS=windows go vet ./internal/...`. - [x] No raw format characters.
jay23606
added a commit
to jay23606/flutter-probe
that referenced
this pull request
Nov 17, 2026
…arer device messages (AlphaWaveSystems#791) ## Summary Follow-ups from the review of AlphaWaveSystems#789. **1. Studio can repair an old iOS device that is not a UDID.** Since AlphaWaveSystems#784, `config.Load` refuses a `device.ios_device_id` that is not a UDID, and Studio's Settings load went through it. So a `probe.yaml` written before that rule (`ios_device_id: iPhone 16`) could not be opened in Settings, and a save then failed with a misleading "probe.yaml changed on disk since the form was loaded". - `config.LoadForRepair(dir)` reads `probe.yaml` like `Load`, except that a non-UDID `ios_device_id` is kept and its error is returned on its own (`*config.IOSDeviceIDError`). Every other rule still fails it. Only an editor uses it; a run keeps `Load`, which still refuses. - `LoadWorkspaceSettings` uses it. It sets the new `iosDeviceIdProblem` field: the value, that it is not a UDID, the pointer to `probe device list`, and that a run refuses the file until it is fixed. The form shows that as text under the iOS field (`settings-ios-problem`; `textContent`, never markup). `models.ts` has the field. - Saving a UDID in its place repairs the file. Saving another field with the old value left as it is still lands: only a changed iOS device is held to the rule. - **The misleading message:** when the file on disk can't be read by the engine, there is nothing to compare with, so Save no longer reports a change on disk. The existing checks refuse with the real reason ("would not load", "not a map"). **2. Tests for the three survivors of the AlphaWaveSystems#789 review:** - the "only when changed" condition; - trimming before the rule; - the `probe device list` pointer in the `config.LoadFile` error. **3. A behavioural test instead of the source check.** The device choice of `probe test` is now one function, `pickLocalDevice`, with the device list passed in. `TestPickLocalDevice` drives it: the platform comes from the list, the iOS rule is checked once the platform is known, the preferences apply, the first device is used when none is named, and a run with no device fails. **4. The edge message.** With `defaults.platform: ios` and an Android serial that is not in the device list, the message now says the serial is not in the device list (see `probe device list`), and that for an iOS device it must be a UDID. It no longer says "invalid --device for an iOS device". Docs: `platform/ios.md` says an older value still opens in Studio's Settings so it can be replaced, and how an unlisted serial is reported. ## Tests - `studio/ios_device_repair_test.go`: - **show and repair:** the value is shown with the problem; saving a UDID makes `config.Load` pass, and the problem is gone; - **an unchanged bad value doesn't block another field**, and stays; - **a UDID with spaces around** is saved trimmed; - **an unreadable `probe.yaml`** is refused with "would not load", not "changed on disk", and the file is unchanged. - `internal/config/ios_device_id_test.go`: the `Load` error points at `probe device list`. `LoadForRepair` keeps the value and the other fields and reports the iOS error on its own, while still refusing an invalid `project.app`. - `internal/cli/ios_device_flag_test.go`: `TestPickLocalDevice`, 10 cases. It replaces AlphaWaveSystems#789's source check. ## Mutation check Each mutant was applied, the tests were run, and the file was restored byte for byte. All 10 were killed. One did not compile at first and was rewritten. | Mutant | Result | |---|---| | Studio loads strictly (`config.Load`) | killed | | no problem shown | killed | | disk compared even when unreadable | killed | | the rule holds an unchanged value | killed | | no trimming before the rule | killed | | platform not taken from the device list | killed | | iOS rule gone | killed | | not-in-the-list message gone | killed | | config error without the pointer | killed | | the repair load fails on the iOS id | killed | ## Test plan - [x] `go test ./internal/cli/ ./internal/config/` passes. - [x] `go test -race -count=1 ./studio/...` (stub `frontend/dist`): `studio` ok in 214 s, `studio/e2e` ok, no data race. - [x] `tsc --noEmit` in `studio/frontend` passes (with an existing `node_modules`; nothing installed, `package-lock.json` unchanged). - [x] `staticcheck` on `cli`, `config` and `studio`; its one finding is S1011, which is already on `main` and fixed by AlphaWaveSystems#790. - [x] `GOOS=windows go vet ./internal/...`. - [x] No raw format characters.
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
Follow-ups from the review of #780: a device id that is not one is now refused where it would act, not later.
device.ios_device_idmust be a UDID. It becomes the iOS device serial (internal/cli/test.go), and a simulator id shapes host paths. Until now it was not validated:config.ValidateDeviceSerialallows/and., and does not see this key.config.LoadFilenow refuses anything but a simulator UDID or a device UDID (ios.ValidSimulatorUDID/ios.ValidDeviceUDID), with a message that names the key and says where to find the id.probe.yamlthat put a device name there. As the--deviceserial, a name with a space already failed.DeviceCtl.Terminateno longer hides a failed process lookup. It returned nil, meaning "not running", wheneverFindPIDfailed, including for an id fix(ios): a device or simulator id no longer shapes a file path #780 refuses. So on a physical iPhone a kill could pass silently and a relaunch could start beside a running app. It now returns the lookup error, andKillAppprintsthe app was not stopped: …in one line. The error quotes the id with%q.SimCtl.ReadTokenfails fast for an id that is not a simulator UDID (a physical device's, or not an id), instead of polling for the whole timeout.SimCtl.tokenFileCandidates: the app's container, every data container, then the legacy device-level file. With an id that is not a simulator UDID it returns no path at all, the legacy file included. It is testable on its own; that mutant survived in fix(ios): a device or simulator id no longer shapes a file path #780..jsonfile one folder above the temporary folder.Docs:
advanced/configuration.md(theios_device_idrow) andplatform/ios.mdsay the value must be a UDID. Their example is a valid UUID.Tests
TestTokenFileCandidatesNeedASimulatorUDID: no paths for a device UDID or any of fix(ios): a device or simulator id no longer shapes a file path #780's hostile ids. A simulator's list ends with the legacy file.TestReadTokenFailsFastForAnIDThatIsNotASimulator: a hostile id, a device UDID and an empty id are each refused in under a second, with a 5 s timeout.TestTerminateReportsALookupFailure: a refused id gives the lookup error, and the fakexcrunnever runs.TestKillOnAPhysicalIPhoneWarnsWhenTheLookupFails: the warning line is printed.TestIOSDeviceIDMustBeAUDID: empty, a UUID, a 25-character and a 40-character device UDID load.../../x,/etc,iPhone 16, a UUID with/../xand*are refused with the key named.Mutation check
Each mutant was applied, the tests were run, and the file was restored byte for byte. All 5 were killed.
ReadTokendoes not fail fastTerminatehides the lookup failureKillAppdrops the warningios_device_idTest plan
go test ./internal/ios/ ./internal/config/ ./internal/runner/ ./internal/cli/passes.go vetandstaticcheckpass on the changed packages.