Add nightly Vercel env var drift detection workflow#754
Add nightly Vercel env var drift detection workflow#754kilo-code-bot[bot] wants to merge 1 commit intomainfrom
Conversation
|
|
||
| async function fetchEnvVars(projectName) { | ||
| const url = new URL(`https://api.vercel.com/v10/projects/${encodeURIComponent(projectName)}/env`); | ||
| url.searchParams.set("teamId", process.env.VERCEL_TEAM_ID); |
There was a problem hiding this comment.
[WARNING]: Missing guard for VERCEL_TEAM_ID
If the VERCEL_TEAM_ID secret is not configured, process.env.VERCEL_TEAM_ID will be undefined, and url.searchParams.set("teamId", undefined) will set the query parameter to the literal string "undefined". This could cause the Vercel API to return an error or unexpected results.
The file header (line 8) implies this is conditionally needed ("if projects are under a team"), but there's no guard here. Consider either:
- Making it required and failing fast if missing, or
- Conditionally adding the param:
if (process.env.VERCEL_TEAM_ID) {
url.searchParams.set("teamId", process.env.VERCEL_TEAM_ID);
}| const allEnvs = []; | ||
| let nextUrl = url.toString(); | ||
|
|
||
| while (nextUrl) { |
There was a problem hiding this comment.
[WARNING]: Pagination loop has no upper bound
If the Vercel API returns the same pagination.next cursor repeatedly (due to a bug or API change), this while (nextUrl) loop will run indefinitely, causing the workflow to hang until the GitHub Actions timeout (6 hours by default).
Consider adding a max iteration guard:
const MAX_PAGES = 20;
let page = 0;
while (nextUrl && page++ < MAX_PAGES) {| } | ||
|
|
||
| const data = await res.json(); | ||
| const envs = data.envs ?? data; |
There was a problem hiding this comment.
[SUGGESTION]: Silent fallback on unexpected API response shape
data.envs ?? data falls back to the entire response object if envs is missing. Combined with the Array.isArray check on the next line, this means an unexpected API response shape would silently produce zero env vars for that page — no error, no warning. This could mask a real problem (e.g., API version change).
Consider logging a warning when the response shape is unexpected:
const envs = data.envs;
if (!envs) {
core.warning(`Unexpected Vercel API response shape for ${projectName} — missing 'envs' key`);
}
allEnvs.push(...(Array.isArray(envs) ? envs : []));
Code Review SummaryStatus: 3 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (1 file)
|
Summary
.github/workflows/verify-vercel-env-vars.yml) that compares environment variable keys across three Vercel projects (kilocode-app,kilocode-global-app,kilocode-gateway) for each target environment (production, preview, development).VERCEL_URL,VERCEL_GIT_*) that are expected to differ.How it works
workflow_dispatchtrigger).Required secrets
VERCEL_TOKENVERCEL_TEAM_IDSLACK_ENV_DRIFT_WEBHOOK_URLBuilt for Remon Oldenbeuving by Kilo for Slack