Skip to content

bug report: Metadata can become corrupted and requires manual clearing #16245

Description

@neowenmsft

Describe the bug
If template metadata cache JSON is corrupted, CLI commands that read template metadata can fail with a JSON parse exception instead of recovering.

This impacts flows that depend on template metadata loading (for example, template listing and command initialization paths that read template metadata).

To Reproduce

  1. Corrupt the template metadata cache file:
    • File: ~/.fx/metadata/allTemplates.json
    • Example invalid content: {"badJson":
    • I've seen this organically several times, probably due to cancelled execution.
  2. Ensure metadata version marker files exist:
    • ~/.fx/template-version-v4.txt
    • ~/.fx/template-version.txt
  3. Run a CLI command that reads templates metadata, for example:
atk list templates --format json
  • CLI exits with an error.
  • Error contains a JSON parse failure (for example, SyntaxError: Unexpected end of JSON input).
  • Corrupted cache file and version markers remain, so the bad state persists.

Expected behavior

  • CLI should not crash due to corrupted cache JSON.
  • On corrupted cache detection, CLI should recover automatically by:
    • removing invalid cached metadata JSON,
    • clearing relevant metadata version marker files so metadata can be repopulated,
    • falling back to bundled metadata for the current operation.
  • Command should complete successfully when bundled metadata is available.

VS Code Extension Information (please complete the following information):

  • OS: [e.g. iOS]
  • Version [e.g. 22]

CLI Information (please complete the following information):

  • OS: Windows 11
  • Version : Latest commit at time of filing

Additional context
PR incoming with fix.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingneeds attentionThis issue needs the attention of a contributor.

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions