{"record":{"id":"313b8f2989a34709","repo":"facebook/relay","slug":"unexpected-rawstring","errorCode":null,"errorMessage":"Unexpected RawString","messagePattern":"Unexpected RawString","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/crates/relay-codegen/src/printer.rs","lineNumber":931,"sourceCode":"                    for ObjectEntry { key: name, value } in obj {\n                        write!(f, \"\\\\\\\"{name}\\\\\\\":\")?;\n                        write_constant_value(f, builder, value)?;\n                        f.push(',');\n                    }\n                    if !obj.is_empty() {\n                        f.pop();\n                    }\n                    f.push('}');\n                    Ok(())\n                }\n            }\n        }\n        Primitive::Null | Primitive::SkippableNull => {\n            f.push_str(\"null\");\n            Ok(())\n        }\n        Primitive::StorageKey(_, _) => panic!(\"Unexpected StorageKey\"),\n        Primitive::RawString(_) => panic!(\"Unexpected RawString\"),\n        Primitive::GraphQLModuleDependency(_) => panic!(\"Unexpected GraphQLModuleDependency\"),\n        Primitive::JSModuleDependency { .. } => panic!(\"Unexpected JSModuleDependency\"),\n        Primitive::ResolverModuleReference { .. } => panic!(\"Unexpected ResolverModuleReference\"),\n        Primitive::PropertyAccessor(_) => panic!(\"Unexpected PropertyAccessor\"),\n        Primitive::DynamicImport { .. } => panic!(\"Unexpected DynamicImport\"),\n        Primitive::RelayResolverModel { .. } => panic!(\"Unexpected RelayResolver\"),\n    }\n}\n","sourceCodeStart":913,"sourceCodeEnd":940,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/compiler/crates/relay-codegen/src/printer.rs#L913-L940","documentation":"write_constant_value handles only constant-printable Primitives; Primitive::RawString is an internal marker (raw code emitted verbatim, typically as a top-level statement or via a dedicated writer) that is invalid inside a constant value such as an argument literal. Encountering it in write_constant_value means a RawString leaked into literal printing, so the printer panics.","triggerScenarios":"Printing an argument or embedded constant whose builder produced Primitive::RawString — e.g. raw string artifacts injected into lists/objects/arguments instead of the intended string literal (Primitive::String); custom transform inserting raw code into a value position.","commonSituations":"Custom IR transforms or patched codegen that emit RawString for dynamic code inside arguments; builder misuse when constructing Primitives for arguments; compiler version drift where a RawString is produced where String is expected.","solutions":["Find the transform that produces Primitive::RawString for the affected argument and use Primitive::String (an actual literal) instead","Replace the raw-string content with a proper literal value in the document/argument (quote it as a real string)","Verify the value path: strings intended for output should use Primitive::String, not RawString","If on a patched/older compiler, update to a release where this invariant holds"],"exampleFix":"// before\nPrimitive::RawString(\"hello\".to_string()) // in an argument value\n// after\nPrimitive::String(\"hello\".to_string())","handlingStrategy":"validation","validationCode":"// Ensure string arguments are real literals:\nfunction assertLiteralStrings(doc) {\n  visit(doc, {\n    Argument(node) {\n      if (node.value.kind === 'StringValue' && node.value.block && node.value.value.includes('\\n')) {\n        throw new Error(`Use a normal StringValue for argument ${node.name.value}`);\n      }\n    }\n  });\n}","typeGuard":"const isPrintableConstant = (p) => p.kind !== 'RawString';","tryCatchPattern":"try {\n  generateArtifacts();\n} catch (e) {\n  if (String(e).includes('Unexpected RawString')) {\n    // replace RawString with a proper String literal in the transform\n  }\n  throw e;\n}","preventionTips":["Use Primitive::String (not RawString) for argument value content","Only use RawString in writers that handle raw code emission","Review custom transforms before merging into codegen paths","Compile all documents in CI to catch invariant breaks early"],"tags":["compiler","codegen","raw-string","primitive"],"backgroundTag":"unexpected-primitive-kind","analyzedSha":"668b1b85e06261aa3b58dabfc51f8b5524a70955","analyzedAt":"2026-09-02T19:57:20.783Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}