fix: return AlreadyExists when archive exists by dankeboy36 · Pull Request #3050 · arduino/arduino-cli (original) (raw)

Please check if the PR fulfills these requirements

See how to contribute

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

When a client archives a sketch via gRPC and the archiveTarget already exists, the CLI correctly errors, but with the incorrect status code. The status code is 3 (illegal argument) instead of 6 (already exists).
Currently, clients must parse the error message if they want to handle the archive -> fail -> archive with override flow. This might not work reliably with translations.

What is the new behavior?

The CLI errors with the correct already exists status code when archiving a sketch, and the archive target already exists.

Does this PR introduce a breaking change, and is titled accordingly?

Actually, this is a breaking change, but I do not know if any client is explicitly handling status code 3. The Arduino IDE 2.x just wipes the target if it exists: https://github.com/arduino/arduino-ide/blob/4d6cfad0ff603a106efd68ffe015d6fc7449f5fc/arduino-ide-extension/src/node/sketches-service-impl.ts#L637-L639

Other information