{"record":{"id":"0f4585efb7e77e88","repo":"microsoft/typescript-go","slug":"w-getsymbolsinscope-requires-a-location","errorCode":null,"errorMessage":"%w: getSymbolsInScope requires a location","messagePattern":"%w: getSymbolsInScope requires a location","errorType":"validation","errorClass":"ErrClientError","httpStatus":null,"severity":"error","filePath":"internal/api/session.go","lineNumber":1615,"sourceCode":"\t}\n\n\treturn setup.newSymbolResponse(symbol), nil\n}\n\n// handleGetSymbolsInScope returns all symbols with the given meaning that are visible at a location.\nfunc (s *Session) handleGetSymbolsInScope(ctx context.Context, params *GetSymbolsInScopeParams) ([]*SymbolResponse, error) {\n\tsetup, err := s.setupChecker(ctx, params.Snapshot, params.Project)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer setup.done()\n\n\tlocation, err := setup.resolveLocation(params.Location, params.File, params.Position)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif location == nil {\n\t\treturn nil, fmt.Errorf(\"%w: getSymbolsInScope requires a location\", ErrClientError)\n\t}\n\n\tsymbols := setup.checker.GetSymbolsInScope(location, ast.SymbolFlags(params.Meaning))\n\tresults := make([]*SymbolResponse, len(symbols))\n\tfor i, symbol := range symbols {\n\t\tresults[i] = setup.newSymbolResponse(symbol)\n\t}\n\n\treturn results, nil\n}\n\n// handleGetSignaturesOfType returns the call or construct signatures of a type.\nfunc (s *Session) handleGetSignaturesOfType(ctx context.Context, params *GetSignaturesOfTypeParams) ([]*SignatureResponse, error) {\n\tsetup, err := s.setupChecker(ctx, params.Snapshot, params.Project)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer setup.done()","sourceCodeStart":1597,"sourceCodeEnd":1633,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/internal/api/session.go#L1597-L1633","documentation":"getSymbolsInScope requires a location to enumerate visible symbols, and resolveLocation returned nil without error: the request carried neither a non-empty location node handle nor both file and position. Any subset (file without position, position without file, or nothing) triggers this guard.","triggerScenarios":"Sending params with all three optional fields (location, file, position) absent or empty; serializing pointers as null via omitempty so both sides of the file+position pair disappear; sending only file or only position.","commonSituations":"Client structs with omitempty on both file and position where one is zero-valued; refactors that pass a location handle from an unrelated response (empty string when unset); UI events that carry a cursor offset but no document.","solutions":["Send either a location node handle obtained from a prior symbol/AST query, or both file and position together","Validate the pair client-side: file and position must be present or absent as a unit","If you only have an offset, make sure the file identifier accompanies it"],"exampleFix":"// before\ngetSymbolsInScope(snap, proj, {meaning: 1}) // no location at all\n\n// after\npos := uint32(120)\ngetSymbolsInScope(snap, proj, {file: &api.DocumentIdentifier{FileName: \"/abs/a.ts\"}, position: &pos, meaning: 1})","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func hasScopeLocation(p *api.GetSymbolsInScopeParams) bool {\n    if p == nil { return false }\n    if p.Location != \"\" { return true }\n    return p.File != nil && p.Position != nil // file and position must arrive as a pair\n}","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"requires a location\") {\n    // request-shape bug: add location handle or file+position, then re-send\n}","preventionTips":["Treat file+position as one composite field; serialize both or neither","Beware omitempty zeroing position (0 is a valid offset) — use pointers as the struct does","Reuse node handles returned by earlier symbol queries as the location anchor"],"tags":["symbol","scope","location","validation","api"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}