fix(backend): rename BRAVE_API_KEY → SERPER_API_KEY across config and routes#185
fix(backend): rename BRAVE_API_KEY → SERPER_API_KEY across config and routes#185leocagli wants to merge 1 commit into
Conversation
Closes Stellar-Ecosystem#16 The /demo/search route calls google.serper.dev but the env var and config key were named BRAVE_API_KEY / braveApiKey — a holdover from an earlier implementation that confuses operators and makes the .env.example example value misleading. Rename across all three files: - backend/.env.example: BRAVE_API_KEY → SERPER_API_KEY - backend/src/config.js: braveApiKey → serperApiKey - backend/src/routes/services.js: config.braveApiKey → config.serperApiKey No behaviour change — only the env var name and config property key change.
📝 WalkthroughWalkthroughThree files are updated to rename the Serper API key identifier from ChangesSerper API Key Rename
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/.env.example`:
- Line 24: The README.md contains outdated documentation that references
BRAVE_API_KEY in the setup instructions, but the actual environment variable
name used throughout the application is SERPER_API_KEY. Update the README.md
setup section to replace all references to BRAVE_API_KEY with SERPER_API_KEY to
align with what is defined in backend/.env.example and used in
backend/src/config.js, ensuring users can correctly configure their environment.
In `@backend/src/config.js`:
- Line 81: The config field has been renamed from braveApiKey to serperApiKey,
but test mock objects in the contract and agents test files still reference the
old field name. Update the mock objects in both test files by replacing all
instances of braveApiKey: '' with serperApiKey: '' to align with the updated
config property name and ensure tests pass with the new configuration structure.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 9dbfe8fe-32c7-4830-b289-c6aaa5c2b873
📒 Files selected for processing (3)
backend/.env.examplebackend/src/config.jsbackend/src/routes/services.js
| SEARCH_PRICE=0.001 | ||
| WEATHER_PRICE=0.001 | ||
| BRAVE_API_KEY=your_serper_api_key | ||
| SERPER_API_KEY=your_serper_api_key |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Find all references to BRAVE_API_KEY in documentation and config files
# Search for BRAVE_API_KEY references
rg -n 'BRAVE_API_KEY' --type=md --type=txt -g '!*.example'
# Also check for braveApiKey in documentation
rg -n 'braveApiKey' --type=md --type=txtRepository: Stellar-Ecosystem/lodestar
Length of output: 168
🏁 Script executed:
# Get the README.md content around the mentioned lines
cat -n README.md | sed -n '120,135p'Repository: Stellar-Ecosystem/lodestar
Length of output: 466
🏁 Script executed:
# Search more broadly for all BRAVE_API_KEY references
rg -n 'BRAVE_API_KEY' -g '!*.example'Repository: Stellar-Ecosystem/lodestar
Length of output: 168
🏁 Script executed:
# Verify that SERPER_API_KEY is the actual replacement
rg -n 'SERPER_API_KEY' -B2 -A2Repository: Stellar-Ecosystem/lodestar
Length of output: 290
Update README.md line 130 to reference SERPER_API_KEY instead of BRAVE_API_KEY.
The setup instructions reference the outdated BRAVE_API_KEY, but the actual environment variable is SERPER_API_KEY (defined in backend/.env.example and used in backend/src/config.js). Users following the README will be unable to configure the application correctly.
🧰 Tools
🪛 dotenv-linter (4.0.0)
[warning] 24-24: [UnorderedKey] The SERPER_API_KEY key should go before the WEATHER_PRICE key
(UnorderedKey)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@backend/.env.example` at line 24, The README.md contains outdated
documentation that references BRAVE_API_KEY in the setup instructions, but the
actual environment variable name used throughout the application is
SERPER_API_KEY. Update the README.md setup section to replace all references to
BRAVE_API_KEY with SERPER_API_KEY to align with what is defined in
backend/.env.example and used in backend/src/config.js, ensuring users can
correctly configure their environment.
| }, | ||
|
|
||
| braveApiKey: process.env.BRAVE_API_KEY ?? '', | ||
| serperApiKey: process.env.SERPER_API_KEY ?? '', |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Find test files that reference braveApiKey and need updating
# Search for braveApiKey in test files
rg -n 'braveApiKey' --type=js --glob='*test*' --glob='*spec*'
# Also check for any other JavaScript files that may reference it
rg -n 'braveApiKey' --type=js -g '!node_modules'Repository: Stellar-Ecosystem/lodestar
Length of output: 298
🏁 Script executed:
# Check for braveApiKey in non-test files to see if this is a complete refactoring
rg -n 'braveApiKey' --type=js --glob='!*test*' --glob='!*spec*' -g '!node_modules'Repository: Stellar-Ecosystem/lodestar
Length of output: 52
🏁 Script executed:
# Examine the test files to see the exact context of the mocks that need updating
head -20 backend/src/lib/contract.test.js | tail -15Repository: Stellar-Ecosystem/lodestar
Length of output: 569
🏁 Script executed:
head -40 backend/src/routes/agents.test.js | tail -10Repository: Stellar-Ecosystem/lodestar
Length of output: 526
🏁 Script executed:
# Verify the config.js file shows the renamed field
cat -n backend/src/config.js | head -85 | tail -10Repository: Stellar-Ecosystem/lodestar
Length of output: 489
Update test mocks to use the renamed config field.
The config field has been renamed from braveApiKey to serperApiKey, but test mocks still reference the old name. Update the following locations:
backend/src/lib/contract.test.js:9backend/src/routes/agents.test.js:36
Change braveApiKey: '' to serperApiKey: '' in both test mock objects. Tests will fail without these updates.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@backend/src/config.js` at line 81, The config field has been renamed from
braveApiKey to serperApiKey, but test mock objects in the contract and agents
test files still reference the old field name. Update the mock objects in both
test files by replacing all instances of braveApiKey: '' with serperApiKey: ''
to align with the updated config property name and ensure tests pass with the
new configuration structure.
Fixes #16
Problem
/demo/searchcalls the Serper API (https://google.serper.dev/search) but the env var was namedBRAVE_API_KEY— a leftover from a previous Brave Search integration. The.env.examplehadBRAVE_API_KEY=your_serper_api_keywhich is contradictory and confusing for anyone setting up the project.Changes
backend/.env.exampleBRAVE_API_KEY→SERPER_API_KEYbackend/src/config.jsbraveApiKey: process.env.BRAVE_API_KEY→serperApiKey: process.env.SERPER_API_KEYbackend/src/routes/services.jsconfig.braveApiKey→config.serperApiKeyNo behaviour change — only the env var name and config property key change.
🤖 Generated with Claude Code
Summary by CodeRabbit