{"record":{"id":"b6d359529f9e7742","repo":"apple/pkl","slug":"commandmustnotassignoramendproperty","errorCode":"commandMustNotAssignOrAmendProperty","errorMessage":"commandMustNotAssignOrAmendProperty","messagePattern":"commandMustNotAssignOrAmendProperty","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/runtime/CommandSpecParser.java","lineNumber":1239,"sourceCode":"    var result = VmValue.export(VmUtils.readMember(value, key));\n    return result instanceof PNull ? null : (String) result;\n  }\n\n  /** Check a value and its parents to see if any assign/amend the given property */\n  private void checkPropertyIsUndefined(VmTyped value, Identifier name) {\n    var member = VmUtils.findMember(value, name);\n    if (member == null) return;\n\n    var memberNode = member.getMemberNode();\n    var sourceSection =\n        memberNode == null\n            ? member.getSourceSection()\n            : memberNode.getBodyNode() instanceof DefaultPropertyBodyNode\n                ? null\n                : memberNode.getSourceSection();\n\n    if (sourceSection != null) {\n      throw exceptionBuilder()\n          .evalError(\"commandMustNotAssignOrAmendProperty\", name)\n          .withSourceSection(sourceSection)\n          .build();\n    }\n  }\n\n  private VmExceptionBuilder exceptionBuilder() {\n    return new VmExceptionBuilder();\n  }\n\n  // endregion\n}\n","sourceCodeStart":1221,"sourceCodeEnd":1252,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/runtime/CommandSpecParser.java#L1221-L1252","documentation":"Pkl CLI commands (e.g. codegen/eval commands built from a Pkl spec) read their option values from a base module, but that module's properties must be supplied, not computed by assignment or amendment. checkPropertyIsUndefined throws `commandMustNotAssignOrAmendProperty` naming the offending property when the property is explicitly assigned or amended in the spec module rather than left for the command to define.","triggerScenarios":"A command's base Pkl module (e.g. a `pkl.project`/generator spec passed to a CLI command) contains `name = \"x\"` or an amend expression for a property the command reserves (like `output`, `format`, etc.), detected at CommandSpecParser.checkPropertyIsUndefined.","commonSituations":"Hand-editing a generated PklProject/CodeGenerator module and accidentally assigning a reserved property; copying spec modules between commands where property ownership differs; amending a base module to override a reserved key.","solutions":["Remove the assignment/amendment of the named property from the spec module (the error points at the exact source section).","If the value must be configured, supply it through the command's own CLI flag or the property the command expects to set itself.","Use a differently named property for your custom value.","Regenerate the spec module from its canonical template if it drifted."],"exampleFix":"// before: PklProject/amend.pkl\noutput = new Output { ... }\n\n// after: let the command define `output`; configure via allowed means\n// (remove the line, or rename your property)\nmyOutput = new Output { ... }","handlingStrategy":"validation","validationCode":"// in your CI lint, grep the spec module for assignments to reserved properties\ngrep -nE '^\\s*(output|format|engine)\\s*=' generator.pkl && exit 1 || exit 0","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never assign or amend properties reserved by the CLI command in its spec module","Configure such values via the command's flags instead","Use your own prefixed property names for custom settings","Regenerate spec modules from templates rather than hand-editing"],"tags":["pkl","cli","spec-module","reserved-property"],"backgroundTag":"invalid-config-value","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}