-
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Problem:
Validation only checks the existence of meta.variableCollections and meta.variables, so malformed structures can still pass as valid.
References:
- src/utils/typeGuards.ts
Citations:
- src/utils/typeGuards. ts
Code Snippets
src/utils/typeGuards.ts:
export function isLocalVariablesResponse(data: unknown): data is LocalVariablesResponse {
if (typeof data !== 'object' || data === null) return false
const obj = data as Record<string, unknown>
if (typeof obj. meta !== 'object' || obj.meta === null) return false
const meta = obj.meta as Record<string, unknown>
if (typeof meta.variableCollections !== 'object' || meta.variableCollections === null) return false
if (typeof meta.variables !== 'object' || meta.variables === null) return false
return true
}tests/utils/typeGuards.test.ts (valid/invalid fallback validation):
it('should return true for valid LocalVariablesResponse', () => {
const validData = {
meta: {
variableCollections: { 'col-1': {} },
variables: { 'var-1': {} },
},
}
expect(isLocalVariablesResponse(validData)).toBe(true)
})
it('should return false for null', () => {
expect(isLocalVariablesResponse(null)).toBe(false)
})Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working