Skip to content

Commit 1cc6ed4

Browse files
waleedlatif1claude
andcommitted
fix: narrow resolvedIP type guard instead of non-null assertion
Replace urlValidation.resolvedIP! with proper type narrowing by adding !urlValidation.resolvedIP to the guard clause, so TypeScript can infer the string type without a fragile assertion. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f1fd878 commit 1cc6ed4

File tree

1 file changed

+6
-3
lines changed
  • apps/sim/app/api/auth/sso/register

1 file changed

+6
-3
lines changed

apps/sim/app/api/auth/sso/register/route.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,20 @@ export async function POST(request: NextRequest) {
161161
})
162162

163163
const urlValidation = await validateUrlWithDNS(discoveryUrl, 'OIDC discovery URL')
164-
if (!urlValidation.isValid) {
164+
if (!urlValidation.isValid || !urlValidation.resolvedIP) {
165165
logger.warn('OIDC discovery URL failed SSRF validation', {
166166
discoveryUrl,
167167
error: urlValidation.error,
168168
})
169-
return NextResponse.json({ error: urlValidation.error }, { status: 400 })
169+
return NextResponse.json(
170+
{ error: urlValidation.error ?? 'SSRF validation failed' },
171+
{ status: 400 }
172+
)
170173
}
171174

172175
const discoveryResponse = await secureFetchWithPinnedIP(
173176
discoveryUrl,
174-
urlValidation.resolvedIP!,
177+
urlValidation.resolvedIP,
175178
{
176179
headers: { Accept: 'application/json' },
177180
}

0 commit comments

Comments
 (0)