Environment and secrets
Understand the idea
A key can be present in the process and still must not appear in source or in a log line.
The idea
This runner does not set AI_API_KEY, so the first line reads environment and prints missing. The second line uses a local object only so the run can show a present key without reading a real secret from your shell. The report is the word present and the length. The JSON log repeats that report. It does not print sk-demo. Production code should read process.env.AI_API_KEY at the edge and pass the value into the client that needs it. Do not commit that value. Do not put it in a fixture that ships.
What changes
| Place | Safe? | What to store instead |
|---|---|---|
| Environment variable | Yes, on the machine that runs the process | The key |
| Source file | No | Nothing. Read the environment |
| Log line | No | present or missing |
| Response body | No | An error that does not echo the header |
The command
Report presence, not the key
3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.
The mistake
Check the result
The lines are missing, then present 7, then a JSON log whose key field is present 7. The characters sk-demo are not in the output.
Guided challenge
Report presence, not the key
report currently returns the raw key. Change it so a present key prints present and the length, never the characters.
Report presence, not the key
3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.
EXPECTED RESULT
missing present 7
Hints 0/2
Use all hints or make 3 failed checks (0/3).
Free exploration
Change this example and run it again. Each run is a new process. Nothing is saved.
Your variation
3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.
Quiz
A quick check for understanding. Retry as often as you like; your learning path stays open.
Ready to call this one understood?
Mark this lesson complete to earn 200 XP. You can always revisit it.