Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/commands/dev/programmatic-netlify-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const startNetlifyDev = async ({

if (process.env.NETLIFY_DB_URL) {
env.NETLIFY_DB_URL = { sources: ['internal'], value: process.env.NETLIFY_DB_URL }
process.env.NETLIFY_DB_DRIVER = 'server'
}
Comment on lines 57 to 60
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟑 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check usage of the env parameter and NETLIFY_DB_DRIVER references

# Search for where StartNetlifyDevOptions.env or the env parameter is used
echo "=== Usage of env parameter from startNetlifyDev ==="
rg -n -C3 'startNetlifyDev' --type=ts

echo -e "\n=== References to NETLIFY_DB_DRIVER in the codebase ==="
rg -n -C3 'NETLIFY_DB_DRIVER' --type=ts

echo -e "\n=== Pattern of env object assignments (to understand structure) ==="
rg -n 'env\.\w+\s*=\s*\{.*sources.*value' --type=ts -A1 -B1

Repository: netlify/cli

Length of output: 2687


🏁 Script executed:

#!/bin/bash

# Check how the env object is passed to netlifyDev and what it expects
echo "=== netlifyDev function and its parameters ==="
rg -n "const netlifyDev\s*=" --type=ts -A5

echo -e "\n=== Where netlifyDev is called/invoked ==="
rg -n "netlifyDev(" --type=ts -B3 -A3

echo -e "\n=== Check programmatic-netlify-dev.ts context around netlifyDev ==="
sed -n '50,80p' src/commands/dev/programmatic-netlify-dev.ts

Repository: netlify/cli

Length of output: 1661


🏁 Script executed:

#!/bin/bash

# Check where startNetlifyDev is called and how the return value is used
echo "=== Callers of startNetlifyDev ==="
rg -n "startNetlifyDev" --type=ts -B2 -A5 | head -80

echo -e "\n=== Check dev.ts full context where startProgrammaticNetlifyDev is used ==="
sed -n '1,150p' src/commands/dev/dev.ts | tail -60

Repository: netlify/cli

Length of output: 3532


🏁 Script executed:

#!/bin/bash

# Find where startProgrammaticNetlifyDev is actually called
echo "=== Call to startProgrammaticNetlifyDev ==="
rg -n "startProgrammaticNetlifyDev\s*\(" --type=ts -B2 -A10

# Also check the complete file structure of dev.ts to see the flow
echo -e "\n=== Lines 130-200 of dev.ts (to see how startProgrammaticNetlifyDev is used) ==="
sed -n '130,200p' src/commands/dev/dev.ts

Repository: netlify/cli

Length of output: 3170


🏁 Script executed:

#!/bin/bash

# Check if injectEnvVariables is called multiple times
echo "=== All calls to injectEnvVariables ==="
rg -n "injectEnvVariables" --type=ts -B2 -A2

# Check the function definition and what it does
echo -e "\n=== injectEnvVariables function definition ==="
rg -n "export.*injectEnvVariables\|function injectEnvVariables" --type=ts -A10

Repository: netlify/cli

Length of output: 4736


🏁 Script executed:

#!/bin/bash

# Check where NETLIFY_DB_URL might be set before startProgrammaticNetlifyDev
echo "=== All references to NETLIFY_DB_URL in dev.ts ==="
sed -n '1,200p' src/commands/dev/dev.ts | rg -n "NETLIFY_DB" || echo "No matches in first 200 lines"

# Check how injectEnvVariables actually works
echo -e "\n=== injectEnvVariables implementation ==="
sed -n '220,240p' src/utils/dev.ts

Repository: netlify/cli

Length of output: 1088


🏁 Script executed:

#!/bin/bash

# Check if NETLIFY_DB_URL is set anywhere else before line 57 of programmatic-netlify-dev.ts
echo "=== All NETLIFY_DB_URL references across codebase ==="
rg -n "NETLIFY_DB_URL" --type=ts -B1 -A1

echo -e "\n=== Check if there's any env object manipulation before startProgrammaticNetlifyDev ==="
sed -n '140,190p' src/commands/dev/dev.ts | rg -n "NETLIFY_DB\|env\s*=" || echo "No matches"

Repository: netlify/cli

Length of output: 4963


Set env.NETLIFY_DB_DRIVER consistently with env.NETLIFY_DB_URL.

Line 58 sets env.NETLIFY_DB_URL using the structured format with { sources: ['internal'], value: ... }, which follows the codebase pattern for internal environment variables. However, line 59 only sets process.env.NETLIFY_DB_DRIVER without setting env.NETLIFY_DB_DRIVER. For consistency with the established pattern (seen in env.NETLIFY_DEV, env.BLOBS_CONTEXT, etc.), also set:

  if (process.env.NETLIFY_DB_URL) {
    env.NETLIFY_DB_URL = { sources: ['internal'], value: process.env.NETLIFY_DB_URL }
+   env.NETLIFY_DB_DRIVER = { sources: ['internal'], value: 'server' }
    process.env.NETLIFY_DB_DRIVER = 'server'
  }
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (process.env.NETLIFY_DB_URL) {
env.NETLIFY_DB_URL = { sources: ['internal'], value: process.env.NETLIFY_DB_URL }
process.env.NETLIFY_DB_DRIVER = 'server'
}
if (process.env.NETLIFY_DB_URL) {
env.NETLIFY_DB_URL = { sources: ['internal'], value: process.env.NETLIFY_DB_URL }
env.NETLIFY_DB_DRIVER = { sources: ['internal'], value: 'server' }
process.env.NETLIFY_DB_DRIVER = 'server'
}
πŸ€– Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/commands/dev/programmatic-netlify-dev.ts` around lines 57 - 60, The code
sets process.env.NETLIFY_DB_DRIVER but doesn't set the structured env object
like env.NETLIFY_DB_URL; update the block that checks process.env.NETLIFY_DB_URL
to also assign env.NETLIFY_DB_DRIVER = { sources: ['internal'], value: 'server'
} (instead of only setting process.env.NETLIFY_DB_DRIVER) so NETLIFY_DB_DRIVER
follows the same internal env pattern as env.NETLIFY_DB_URL.


return netlifyDev
Expand Down
Loading