-
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Problem:
hasFallback is derived from fallbackFile || parsedFallbackFile. If fallbackFile is a string but invalid JSON, parsedFallbackFile becomes undefined, but hasFallback still becomes true. That forces the fallback SWR key even though fallback data can't be parsed, and the fetcher will then try a "fallback" key and "fallback" token, causing a failure.
References:
- src/contexts/FigmaVarsProvider.tsx
- src/hooks/useVariables. ts
- src/hooks/usePublishedVariables.ts
- src/utils/swrKeys.ts
Citations:
- src/contexts/FigmaVarsProvider.tsx
- src/hooks/useVariables.ts
- src/hooks/usePublishedVariables.ts
- src/utils/swrKeys.ts
Code Snippets
src/hooks/useVariables.ts:
const hasFallback = Boolean(fallbackFile || parsedFallbackFile)
const key = getVariablesKey({
fileKey,
token,
providerId,
hasFallback,
})src/hooks/usePublishedVariables.ts:
const hasFallback = Boolean(fallbackFile || parsedFallbackFile)
const key = getPublishedVariablesKey({
fileKey,
token,
providerId,
hasFallback,
})src/contexts/FigmaVarsProvider.tsx:
const parsedFallbackFile = useMemo(() => {
if (!fallbackFile) return undefined
// If already parsed (object), validate...
if (typeof fallbackFile === 'object') { ... }
// If string, parse JSON
// ...
}, [fallbackFile])src/utils/swrKeys.ts:
export function getVariablesKey(params: VariablesKeyParams): readonly [string, string] | null {
const { fileKey, token, providerId, hasFallback } = params
if (hasFallback) {
return [`fallback-${providerId ?? 'default'}`, 'fallback'] as const
}
if (token && fileKey) {
// ...
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working