Skip to content

Store migration fails with "Migration source has an unexpected file type" when gateways\ contains any file (e.g. native-setup-draft.json) #1723

Open

Description

@dompas23

Summary

Store migration cannot prepare when %APPDATA%\OpenClawTray\gateways\ contains any file, because MigrationInventory.GetGatewayDirectories enumerates every filesystem entry and then requires each one to be a directory. The app's own SetupEngine writes native-setup-draft.json into exactly that folder, so the two features collide and migration dead-ends with Migration2_ValidationFailed.

Environment

  • Windows Companion (Inno install, 2026.9.8-1) migrating to the Microsoft Store build
  • Gateway 2026.10.2
  • Windows 11

Repro

  1. Set up a native gateway through the SetupEngine (it writes %APPDATA%\OpenClawTray\gateways\native-setup-draft.json).
  2. Start the Store migration (Settings -> "Install Store version and migrate"), accept consent.
  3. The preparation step fails; the dialog shows the Migration2_ValidationFailed message.

Evidence

%LOCALAPPDATA%\OpenClawTray\openclaw-tray.log:

[INFO]  Store migration startup admission: ConsentRequired (receipt: False, source payload: False).
[ERROR] Store migration preparation failed: Migration source has an unexpected file type.

Root cause

src/OpenClaw.Connection/Migration/MigrationInventory.cs (~line 151):

private static string[] GetGatewayDirectories(string roaming)
{
    var path = Path.Combine(roaming, "gateways");
    if (!CheckPath(path, directory: true))
        return [];
    var names = new List<string>();
    foreach (var child in Directory.EnumerateFileSystemEntries(path))   // ~157: files AND directories
    {
        if (names.Count >= MaximumGateways)
            throw new InvalidDataException("Too many gateway identity directories.");
        CheckPath(child, directory: true);                              // ~161: throws for a file
        var name = Path.GetFileName(child);
        ValidateSegment(name);
        names.Add(name);
    }
    return names.Order(StringComparer.Ordinal).ToArray();
}

EnumerateFileSystemEntries returns files and directories. CheckPath(child, directory: true) throws InvalidDataException("Migration source has an unexpected file type.") (~line 246) for any file.

The offending file is written on purpose by src/OpenClaw.SetupEngine/NativeGatewaySetupService.cs:214 (documented in docs/ONBOARDING_WIZARD.md:328):

Path.Combine(Path.GetDirectoryName(registry.GetIdentityDirectory("native-setup"))!, "native-setup-draft.json");

So the migration inventory and the native-gateway setup feature disagree about what may live in gateways\.

Suggested fix

Enumerate directories only (Directory.EnumerateDirectories) or skip non-directory entries, since the rest of the inventory never reads files from gateways\.

Workaround

Move %APPDATA%\OpenClawTray\gateways\native-setup-draft.json out of the gateways\ folder, then Retry. Preparation, completion and finalization then succeed:

[INFO] Store migration preparation completed
[INFO] Store migration completion recorded
[INFO] Store migration startup admission: FinalizationRequired (receipt: True, source payload: False)
[INFO] Store migration finalized

Note

Second, independent blocker in the same migration flow as #1592 / #1676 (the stale, non-numeric Inno DisplayVersion).

Activity

  1. added
    P0Emergency: data loss, security bypass, crash loop, or unusable core runtime.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    impact:ux-release-blockerA non-technical user is blocked without terminal, logs, config, or support.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    on Oct 14, 2026
  2. clawsweeper commented on Oct 14, 2026

    @clawsweeper

    Codex review: this still needs some work.

    Summary
    This issue establishes a current-main migration bug; an existing open PR addresses the native setup draft collision but has not merged.

    Reproducibility: Current main proves the failure: setup writes gateways/native-setup-draft.json and migration requires that same entry to be a directory; the reporter supplies matching logs and a successful file-removal workaround, but this read-only review ran no reproduction or tests.

    Next step
    Review #1675 (fix(migration): Store migration blocked for Native Gateway users and correction releases) for safe draft handling and in-app Retry recovery, then verify this issue before closure.

    Review details

    Best possible solution:

    Recognize and validate the existing setup draft while preserving strict inventory safeguards and allowing users to retry migration within the app.

    Do we have a high-confidence way to reproduce the issue?

    Current main proves the failure: setup writes gateways/native-setup-draft.json and migration requires that same entry to be a directory; the reporter supplies matching logs and a successful file-removal workaround, but this read-only review ran no reproduction or tests.

    Is this the best way to solve the issue?

    The existing PR's exact-name draft handling is safer than skipping every file because it retains bounded inventory, fingerprint consistency, and rejection of unexpected or unsafe entries.

    AGENTS.md: found and applied where relevant.

    Codex review notes: model internal, reasoning medium; reviewed against d096d5381c9f.

    Label changes

    Label changes:

    • add P0: The supported Store migration path blocks an ordinary user and requires log inspection and manual file movement to recover.
    • add impact:ux-release-blocker: Retry cannot overcome the app-created draft collision, and the current UI provides no effective in-product recovery.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.

    Label justifications:

    • P0: The supported Store migration path blocks an ordinary user and requires log inspection and manual file movement to recover.
    • impact:ux-release-blocker: Retry cannot overcome the app-created draft collision, and the current UI provides no effective in-product recovery.
    Evidence reviewed

    What I checked:

    Likely related people:

    • Natalie Aguinaldo: Raw commit 5a59535 adds src/OpenClaw.Connection/Migration/MigrationInventory.cs:157 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5a59535216ee; files: src/OpenClaw.Connection/Migration/MigrationInventory.cs)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge; those execution lanes are retired.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

    Reviewed October 14, 2026, 12:35 PM ET / 16:35 UTC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0Emergency: data loss, security bypass, crash loop, or unusable core runtime.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:ux-release-blockerA non-technical user is blocked without terminal, logs, config, or support.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions