Description
Describe the problem
Arduino Web Editor has a "Secret tab" feature that makes it easy to share sketches without accidentally exposing sensitive data (e.g., passwords or tokens). Secrets are automatically generated for any identifier in the sketch which starts with SECRET_
and contains all uppercase characters.
The values of these secrets can be defined on Arduino Cloud via a form in the "Secret" tab in Arduino Web Editor.
Secrets are also used in Arduino IoT Cloud Thing sketches to store network credentials. The value of these secrets can be set via the Arduino IoT Cloud web interface.
When you download a sketch containing secrets from Arduino Web Editor (via the ●●● > Download Sketch menu item), the downloaded ZIP file includes a file named arduino_secrets.h
that contains #define
directives for the secrets.
When you have defined the value of secrets via the Arduino Cloud web interfaces and then pull the sketch via Arduino IDE's Remote Sketchbook, the arduino_secrets.h
file is added to the sketch.
🐛 However, if you have not defined values for the secrets via the web interface before pulling, then the sketch will not contain this file.
🐛 The sketch will fail to compile and the average user will find it very difficult to manually add the correct file and code for the missing secrets definitions.
To reproduce
- Open Arduino Web Editor.
- Click the New Sketch button.
- Add the following code:
You should see a tab named "Secret" appear. Do not define the value of
char myPassword[] = SECRET_PASSWORD; void setup() {} void loop() {}
SECRET_PASSWORD
. - Start the Arduino IDE.
- Open the sketchbook explorer sidebar (folder icon)
- Click the Remote Sketchbook tab (globe icon)
- Click the "Sign in" button and sign into your Arduino account if not already.
- In the Arduino IDE, click the name of the sketch you created in Arduino Web Editor.
- Click the "Pull" icon (cloud with downward arrow). Wait for the pull to finish.
- Double click the sketch to open it.
🐛 The sketch contains only the primary.ino
file andReadMe.adoc
. - Select Tools > Board > Arduino AVR Boards > Arduino Uno from the Arduino IDE menus.
- Select Sketch > Verify/Compile from the Arduino IDE menus.
🐛 The compilation fails:Compilation error: 'SECRET_PASSWORD' was not declared in this scope
Expected behavior
When a sketch that uses secrets is pulled, it will always contain:
- An
arduino_secrets.h
file with#define
directives for the secret macros - An
#include
directive at the top of the primary sketch file forarduino_secrets.h
(include arduino_secrets when needed #438)
Arduino IDE version
Original report
2.0.0-beta.8-snapshot.491fa19
Last verified with
Operating system
Windows
Operating system version
11
Additional context
I can envision two common use cases where secrets are not defined on Arduino Cloud before pulling the sketch:
- The Arduino IoT Cloud web interface is used for the initial setup of a Thing, but the user wants to do all further sketch development in the IDE.
- A copy of a sketch is created in Arduino Web Editor via the ●●● > Save As menu item (secret values are not transferred to the saved copy of the sketch).
Additional reports:
- https://forum.arduino.cc/t/cant-run-remote-sketch-locally-with-arduino-ide/1076466
- https://forum.arduino.cc/t/wemos-lolin32-unable-to-verify-ota-the-board-didnt-answer-after-reboot/1087777/5
Issue checklist
- I searched for previous reports in the issue tracker
- I verified the problem still occurs when using the latest nightly build
- My report contains all necessary details