{"record":{"id":"f20d96399ded28bc","repo":"dagger/dagger","slug":"unknown-fragment-s","errorCode":null,"errorMessage":"unknown fragment: %s","messagePattern":"unknown fragment: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dagql/server.go","lineNumber":2544,"sourceCode":"\t\t\t\treturn nil, fmt.Errorf(\"parse field %q: %w\", x.Name, err)\n\t\t\t}\n\t\t\tvar subsels []Selection\n\t\t\tif len(x.SelectionSet) > 0 {\n\t\t\t\tsubsels, err = s.parseASTSelections(ctx, gqlOp, resType, x.SelectionSet)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tsels = append(sels, Selection{\n\t\t\t\tAlias:         x.Alias,\n\t\t\t\tSelector:      sel,\n\t\t\t\tSubselections: subsels,\n\t\t\t})\n\t\tcase *ast.FragmentSpread:\n\t\t\tfragment := gqlOp.Doc.Fragments.ForName(x.Name)\n\t\t\tif fragment == nil {\n\t\t\t\treturn nil, fmt.Errorf(\"unknown fragment: %s\", x.Name)\n\t\t\t}\n\t\t\t// Check type condition: only include if the fragment's type matches\n\t\t\t// the current object type (or is empty / matches an interface).\n\t\t\tif s.typeConditionMatches(fragment.TypeCondition, self.Name()) {\n\t\t\t\tif len(fragment.SelectionSet) > 0 {\n\t\t\t\t\t// Parse against the fragment's type condition if it differs\n\t\t\t\t\t// from the current context (e.g. narrowing from an interface).\n\t\t\t\t\tfragSelf := self\n\t\t\t\t\tif fragment.TypeCondition != \"\" && fragment.TypeCondition != self.Name() {\n\t\t\t\t\t\tfragSelf = &ast.Type{NamedType: fragment.TypeCondition, NonNull: true}\n\t\t\t\t\t}\n\t\t\t\t\tsubsels, err := s.parseASTSelections(ctx, gqlOp, fragSelf, fragment.SelectionSet)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\tsubsels = addTypeCondition(subsels, fragment.TypeCondition)\n\t\t\t\t\tsels = append(sels, subsels...)\n\t\t\t\t}","sourceCodeStart":2526,"sourceCodeEnd":2562,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/dagql/server.go#L2526-L2562","documentation":"A GraphQL fragment spread references a fragment definition that does not exist in the operation document (gqlOp.Doc.Fragments.ForName returns nil). dagql requires the spread to resolve to a declared fragment.","triggerScenarios":"A query sends `...FragmentName` in a selection set but the fragment `fragment FragmentName on X { ... }` is missing from the document, or its name is misspelled.","commonSituations":"Programmatically built queries omitting the fragment definition while spreading it; string concatenation of query parts dropping fragments; renaming a fragment in one place only.","solutions":["Add the missing `fragment FragmentName on Type { ... }` definition to the query document","Fix the spelling mismatch between the spread and the fragment definition","If building queries in code, ensure fragment definitions are collected and attached to the operation","Run the query through a graphql parser/validator before sending"],"exampleFix":"// before\n{ node(id: \"x\") { ...TreeFields } }\n// after\nfragment TreeFields on Node { id name }\n{ node(id: \"x\") { ...TreeFields } }","handlingStrategy":"validation","validationCode":"for _, spread := range collectSpreads(doc) {\n    if doc.Fragments.ForName(spread.Name) == nil {\n        return fmt.Errorf(\"document references undefined fragment %s\", spread.Name)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always co-locate fragment definitions with spreads","When concatenating query strings, collect fragments programmatically","Run gqlparser validation on every outgoing query","Grep renamed fragments for stale spread references"],"tags":["dagql","graphql","fragment"],"backgroundTag":"unknown-graphql-fragment","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}