-
Notifications
You must be signed in to change notification settings - Fork 469
feat: support NETLIFY_DEV_JWT_SECRET env var for dev identity JWT #8417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,11 @@ const getErrorMessage = function ({ message }) { | |
| // - `from` is called `origin` | ||
| // - `query` is called `params` | ||
| // - `conditions.role|country|language` are capitalized | ||
| // Leading and trailing whitespace in `from` and `to` is trimmed so that typos | ||
| // such as `to = " https://example.com"` do not silently break redirects | ||
| // (see https://github.com/netlify/cli/issues/4707). | ||
| const trimValue = (value) => (typeof value === 'string' ? value.trim() : value) | ||
|
|
||
| const normalizeRedirect = function ({ | ||
| // @ts-expect-error TS(7031) FIXME: Binding element 'country' implicitly has an 'any' ... Remove this comment to see the full error message | ||
| conditions: { country, language, role, ...conditions }, | ||
|
|
@@ -45,11 +50,15 @@ const normalizeRedirect = function ({ | |
| query, | ||
| // @ts-expect-error TS(7031) FIXME: Binding element 'signed' implicitly has an 'any' t... Remove this comment to see the full error message | ||
| signed, | ||
| // @ts-expect-error TS(7031) FIXME: Binding element 'to' implicitly has an 'any type... | ||
| to, | ||
| ...redirect | ||
| }) { | ||
| return { | ||
| ...redirect, | ||
| origin: from, | ||
| origin: trimValue(from), | ||
| path: trimValue(from), | ||
| to: trimValue(to), | ||
|
Comment on lines
+53
to
+61
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C 8 '\bparseAllRedirects\b|\bnormalizeRedirect\b|config\.redirects\s*=' src
rg -n -C 8 '\bdeploySite\b' srcRepository: netlify/cli Length of output: 9673 🏁 Script executed: set -euo pipefail
printf '%s\n' '--- redirects utility ---'
cat -n src/utils/redirects.ts | sed -n '1,120p'
printf '%s\n' '--- deploy redirect path ---'
cat -n src/commands/deploy/deploy.ts | sed -n '590,670p'
printf '%s\n' '--- redirect utility usages and tests ---'
rg -n -C 5 '\bparseRedirects\b|\bnormalizeRedirect\b|trimValue|parseAllRedirects|redirects' test tests src/commands src/utils 2>/dev/null | head -n 500
printf '%s\n' '--- parser dependency metadata ---'
rg -n -C 3 '"`@netlify/redirect-parser`"|"redirect-parser"' package.json package-lock.json yarn.lock pnpm-lock.yaml 2>/dev/null || trueRepository: netlify/cli Length of output: 44016 🏁 Script executed: set -euo pipefail
printf '%s\n' '--- repository manifests and lockfiles ---'
git ls-files | rg '(^|/)(package\.json|package-lock\.json|yarn\.lock|pnpm-lock\.yaml)$' || true
cat package.json | sed -n '1,220p'
printf '%s\n' '--- deploySite redirect handling ---'
ast-grep outline src/utils/deploy/deploy-site.ts
rg -n -C 12 '\bredirects\b|config|deploySite' src/utils/deploy/deploy-site.ts | head -n 300
printf '%s\n' '--- deploy tests and mocks ---'
rg -n -C 8 'commands/deploy|deploy.*redirect|redirect.*deploy|parseAllRedirects|createSiteDeploy|config\.redirects' tests src --glob '*test*' --glob '*spec*' | head -n 500
printf '%s\n' '--- all redirect parser references ---'
rg -n -C 5 '`@netlify/redirect-parser`|parseAllRedirects' . --glob '!node_modules/**' --glob '!dist/**' --glob '!build/**' || trueRepository: netlify/cli Length of output: 15262 🏁 Script executed (no clone): Length of output: 653 🏁 Script executed: set -euo pipefail
python3 - <<'PY'
import json
from pathlib import Path
lock = json.loads(Path('package-lock.json').read_text())
for key, value in lock.get('packages', {}).items():
if key.endswith('node_modules/@netlify/redirect-parser'):
print(json.dumps({
'lockfile_key': key,
'version': value.get('version'),
'resolved': value.get('resolved'),
}, indent=2))
PYRepository: netlify/cli Length of output: 332 🏁 Script executed (no clone): Length of output: 2411 🏁 Script executed (no clone): Length of output: 4751 🏁 Script executed (no clone): Length of output: 10704 🏁 Script executed (no clone): Length of output: 10704 🏁 Script executed: set -euo pipefail
printf '%s\n' '--- config hashing and upload path ---'
ast-grep outline src/utils/deploy/hash-config.ts
cat -n src/utils/deploy/hash-config.ts | sed -n '1,240p'
rg -n -C 12 'hashConfig\(|normalizedPath|config\.redirects|redirects' src/utils/deploy src/commands/deploy/deploy.ts | head -n 500
printf '%s\n' '--- deploy command config construction ---'
rg -n -C 12 'runDeploy|config\s*=|getConfig|loadConfig|parseAllRedirects' src/commands/deploy/deploy.ts | head -n 500
printf '%s\n' '--- redirect whitespace tests and issue references ---'
rg -n -C 8 'whitespace|trim|issue.?4707|leading|trailing|redirects.*deploy|deploy.*redirects' tests src package.jsonRepository: netlify/cli Length of output: 50368 🏁 Script executed: set -euo pipefail
python3 - <<'PY'
from pathlib import Path
redirects = Path('src/utils/redirects.ts').read_text()
deploy = Path('src/commands/deploy/deploy.ts').read_text()
deploy_site = Path('src/utils/deploy/deploy-site.ts').read_text()
assert 'return redirects.map(normalizeRedirect)' in redirects
assert 'configRedirects: config.redirects' in deploy
assert 'minimal: true' in deploy
assert 'config.redirects = redirects' in deploy
assert 'hashConfig({ config })' in deploy_site
# `@netlify/redirect-parser` 16.1.0 normalizes and validates values but does
# not trim programmatic configRedirects.from/to.
config_redirect = {'from': ' /source ', 'to': ' /target ', 'status': 200}
parser_result = dict(config_redirect)
cli_result = {
**config_redirect,
'origin': config_redirect['from'].strip(),
'path': config_redirect['from'].strip(),
'to': config_redirect['to'].strip(),
}
assert parser_result['from'] == ' /source '
assert parser_result['to'] == ' /target '
assert cli_result['origin'] == '/source'
assert cli_result['path'] == '/source'
assert cli_result['to'] == '/target'
print('deploy path receives untrimmed programmatic redirect values')
print('local parseRedirects path trims from/to values')
print('deploySite serializes the resulting config through hashConfig')
PYRepository: netlify/cli Length of output: 318 🏁 Script executed: set -euo pipefail
python3 - <<'PY'
from pathlib import Path
redirects = Path('src/utils/redirects.ts').read_text()
deploy = Path('src/commands/deploy/deploy.ts').read_text()
deploy_site = Path('src/utils/deploy/deploy-site.ts').read_text()
assert 'return redirects.map(normalizeRedirect)' in redirects
assert 'configRedirects: config.redirects' in deploy
assert 'minimal: true' in deploy
assert 'config.redirects = redirects' in deploy
assert 'hashConfig({ config })' in deploy_site
# `@netlify/redirect-parser` 16.1.0 preserves whitespace in programmatic
# configRedirects.from/to values.
config_redirect = {'from': ' /source ', 'to': ' /target ', 'status': 200}
parser_result = dict(config_redirect)
cli_result = {
**config_redirect,
'origin': config_redirect['from'].strip(),
'path': config_redirect['from'].strip(),
'to': config_redirect['to'].strip(),
}
assert parser_result['from'] == ' /source '
assert parser_result['to'] == ' /target '
assert cli_result['origin'] == '/source'
assert cli_result['path'] == '/source'
assert cli_result['to'] == '/target'
print('deploy path receives untrimmed programmatic redirect values')
print('local parseRedirects path trims from/to values')
print('deploySite serializes the resulting config through hashConfig')
PYRepository: netlify/cli Length of output: 318 Normalize config redirects before deployment.
🤖 Prompt for AI Agents |
||
| params: query, | ||
| conditions: { | ||
| ...conditions, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Remove the explanatory block comment.
The warning condition and message already explain the behavior. Delete these comments and keep the executable logic unchanged.
As per coding guidelines, do not write comments describing what the code does; make the code self-explanatory instead.
Proposed change
📝 Committable suggestion
🤖 Prompt for AI Agents
Source: Coding guidelines