{"record":{"id":"a0c1ce4399356a06","repo":"facebook/relay","slug":"unexpected-propertyaccessor","errorCode":null,"errorMessage":"Unexpected PropertyAccessor","messagePattern":"Unexpected PropertyAccessor","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/crates/relay-codegen/src/printer.rs","lineNumber":935,"sourceCode":"                    }\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":917,"sourceCodeEnd":940,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/compiler/crates/relay-codegen/src/printer.rs#L917-L940","documentation":"Primitive::PropertyAccessor is used when printing values that must be read from runtime variables (e.g. `$variables.key` accessors) in generated code paths that support it. write_constant_value only emits static constants, so a PropertyAccessor appearing there means a runtime-dependent value leaked into a constant position and the printer panics instead of emitting invalid literal code.","triggerScenarios":"A value dependent on query variables (yielding a PropertyAccessor primitive, typically after Variables-in-argument handling) reaching write_constant_value — e.g. variable-derived arguments printed in a context that only supports constants, such as nested constant printing in write_argument_value.","commonSituations":"Arguments containing variables in positions codegen expects to be fully static (e.g. @static_arg values, storage-key embedded values with nested variables); custom transforms mislabeling dynamic values; compiler upgrades changing which positions accept variables.","solutions":["Remove variables from argument positions that must be constant (e.g. @static_arg values); use literal values and pass dynamic data at execution time","Ensure the variable-containing argument is printed via the variables-handling path (which filters Variables before constant printing) rather than nested inside constant values","Inspect the custom transforms for mislabeled dynamic values and emit PropertyAccessor only in accessor-supported writers","Upgrade the Relay compiler so variable filtering matches the printer's expectations"],"exampleFix":"// before\n...Frag @static_arg(key: \"id\", value: $dynamicId)\n// after\n...Frag @static_arg(key: \"id\", value: \"static-id\")  // pass dynamicId at runtime instead","handlingStrategy":"validation","validationCode":"function assertStaticStaticArgs(doc) {\n  visit(doc, {\n    Directive(node) {\n      if (node.name.value === 'static_arg') {\n        node.arguments?.forEach(a => {\n          if (containsVariable(a.value)) {\n            throw new Error(`@static_arg value for '${a.name.value}' must not contain variables`);\n          }\n        });\n      }\n    }\n  });\n}","typeGuard":"const isStaticValue = (v) => v.kind !== 'Variable' && !(v.values ?? []).some(isStaticValue === undefined ? false : containsVar(v));","tryCatchPattern":"try {\n  generateArtifacts();\n} catch (e) {\n  if (String(e).includes('Unexpected PropertyAccessor')) {\n    // replace variable-dependent values in constant positions with literals\n  }\n  throw e;\n}","preventionTips":["Never use variables in @static_arg or other constant-required positions","Pass dynamic values via regular query variables at execution time","Verify custom transforms emit PropertyAccessor only in accessor-supported writers","Run full codegen on all documents in CI"],"tags":["compiler","codegen","variables","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"}