Skip to content

[grpc] daemon automatically picks up the sketch profile file although client was not initialized with it #3037

@dankeboy36

Description

@dankeboy36

Describe the problem

If an invalid sketch project file happens to be in the sketch folder, the compile command will fail via gRPC, although I have never initialized my client to use the profile.

It results in an error:

ClientError: /cc.arduino.cli.commands.v1.ArduinoCoreService/Compile NOT_FOUND: Can't open sketch: error loading sketch project file: all platforms in a profile must either require a specific version or not

Please note that the NOT_FOUND status code might need a revisit. It should be INVALID_ARGUMENT or FAILED_PRECONDITION, preferably the latter.

To reproduce

Open a terminal:

./arduino-cli version
arduino-cli  Version: git-snapshot Commit: 28dbc335c Date: 2025-11-09T15:58:02Z
./arduino-cli daemon
Daemon is now listening on http://127.0.0.1:50051/
{"IP":"127.0.0.1","Port":"50051"}

Open another terminal:

buf export . -o ./tmp/out
cat ../vscode-ardunno/test_workspace/empty/empty.ino
void setup() {}
void loop() {}
cat ../vscode-ardunno/test_workspace/empty/sketch.yaml
profiles:
  wroom:
    fqbn: esp32:esp32:esp32da:FlashFreq=40,FlashMode=dio,FlashSize=16M,DebugLevel=none,LoopCore=1,EventsCore=1,EraseFlash=all,CPUFreq=20,PartitionScheme=noota_3g
    platforms:
      - platform: arduino:mbed_edge
      - platform: arduino:mbed_giga (4.4.1)
default_profile: Untitled 2
grpcurl \
  -plaintext \
  -import-path ./tmp/out \
  -proto cc/arduino/cli/commands/v1/commands.proto \
  127.0.0.1:50051/ \
  cc.arduino.cli.commands.v1.ArduinoCoreService.Create
{
  "instance": {
    "id": 1
  }
}
grpcurl \
  -plaintext \
  -import-path ./tmp/out \
  -proto cc/arduino/cli/commands/v1/commands.proto \
  -d '{"instance": {"id": 1}}' \
  127.0.0.1:50051/ \
  cc.arduino.cli.commands.v1.ArduinoCoreService.Init
grpcurl \
  -plaintext \
  -import-path ./tmp/out \
  -proto cc/arduino/cli/commands/v1/commands.proto \
  -d '{"instance": {"id": 1}, "fqbn": "esp32:esp32:esp32da", "sketchPath": "../vscode-ardunno/test_workspace/empty/"}' \
  127.0.0.1:50051/ \
  cc.arduino.cli.commands.v1.ArduinoCoreService.Compile
ERROR:
  Code: NotFound
  Message: Can't open sketch: error loading sketch project file: all platforms in a profile must either require a specific version or not

Remove the profile file:

rm ../vscode-ardunno/test_workspace/empty/sketch.yaml

It works:

grpcurl \                                            
  -plaintext \
  -import-path ./tmp/out \
  -proto cc/arduino/cli/commands/v1/commands.proto \
  -d '{"instance": {"id": 1}, "fqbn": "esp32:esp32:esp32da", "sketchPath": "../vscode-ardunno/test_workspace/empty/"}' \
  127.0.0.1:50051/ \
  cc.arduino.cli.commands.v1.ArduinoCoreService.Compile
{
  "progress": {
    "percent": 4
  }
}
{
  "progress": {
    "percent": 8
  }
}
// rest

Expected behavior

The CLI daemon ignores the profile if the core client was not initialized with it.

Arduino CLI version

28dbc33

Operating system

macOS

Operating system version

15.7.1

Additional context

I am happy to help with anything to get this resolved as soon as possible.

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the nightly build
  • My report contains all necessary details

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: imperfectionPerceived defect in any part of project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions