Skip to content

Global config file can be truncated if process is interrupted during write #441

@MarkArbogast

Description

@MarkArbogast

Describe the bug

The global config file (~/.vmware-aria-operations-integration-sdk/config.json) is updated with a read-then-write pattern: the file is opened for writing (which truncates it) and then the new contents are written. If the process is interrupted (e.g. Ctrl-C) after the file is truncated but before the write finishes, the config file can be left empty or partially written. That can cause commands like mp-build to fail until the config is restored or recreated.

We should be able to address this by writing to a temp file and atomically replacing the original.

Reproduction steps

  1. Run mp-build
  2. Cancel during the config file re-write

Expected behavior

Config file should be preserved

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions