--- title: secret_in_source description: A secret key or credential is written into your code. --- # `secret_in_source` **Severity:** warn. A secret key or credential may be written into your code. The deploy goes on. ## What Kaviris saw One of these, in a file of your source: - a **secret key** of a service Kaviris recognises: Supabase service-role key or `sb_secret_…`, Stripe `sk_…` or `rk_…`, OpenAI `sk-proj-…`, Anthropic `sk-ant-…`; - a credential that was **verified** to work; - a match by a scanner rule written for one specific provider. A committed `.env` file with real values counts too. The warning starts with a label, our guess to help you: - **Probably real:** one of the cases above. - **Unsure:** the match only *looks* like a key (a generic pattern, a token nobody verified). Check that it is not real. Kaviris never blocks a deploy for a secret and cannot tell which are real. Your app's secrets are your responsibility; see [secret_scan](secret_scan.md). ## Why it matters Anyone with your source, or with the built app, can use the key, and source travels: to GitHub, to collaborators, to AI tools. Secrets belong in the app's secret slots, where nobody can read them back. ## How to fix it For a probably real one, the warning names the slot: the variable the key was assigned to, or the usual name for that service. 1. Change the code to read the key from the environment, for example `process.env.OPENAI_API_KEY` instead of the literal. 2. Declare the slot and set the value by reference: ```sh kaviris secrets set OPENAI_API_KEY --from-env OPENAI_API_KEY --declare ``` For a committed `.env` file: `kaviris secrets import .env --declare`, then remove the file from the repository (`git rm --cached .env`, and add `.env` to `.gitignore`). 3. **Rotate the key** with the provider: create a new one and delete the old one. It has been in your source. 4. Deploy again. Agents: the warning's `fix` holds the `slot`, the `command` to run, and the `patch` that declares the slot. Apply the patch (`update_contract`, `approve_contract`), run the command or call `set_secret` without a value, and change the code. See [Secrets](../concepts/secrets.md). [All refusal codes](index.md)