Skip to content

Commit bd01f65

Browse files
fix(tsc): Correct null correctness error in getCsrfToken (#7744)
This would fail anyway without it so this isn't any better or worse, but now we're being correct about always passing a value to the header
1 parent 361a8af commit bd01f65

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/components/codeContext.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,16 @@ export async function fetchCodeKeywords(): Promise<CodeKeywords> {
190190
};
191191
}
192192

193-
function getCsrfToken(): string | null {
193+
function getCsrfToken(): string {
194194
// is sentry-sc in production, but may also be sc in other envs
195195
// So we just try both variants
196196
const cookieNames = ['sentry-sc', 'sc'];
197197

198-
return cookieNames
198+
const value = cookieNames
199199
.map(cookieName => Cookies.get(cookieName))
200200
.find(token => token !== null);
201+
202+
return value ?? '';
201203
}
202204

203205
export async function createOrgAuthToken({

0 commit comments

Comments
 (0)