{"record":{"id":"2895898235e9f41a","repo":"apple/pkl","slug":"invalidoutputfilestructure","errorCode":"invalidOutputFileStructure","errorMessage":"invalidOutputFileStructure","messagePattern":"invalidOutputFileStructure","errorType":"error_code","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/runtime/TestRunner.java","lineNumber":254,"sourceCode":"                  if (actualExampleOutputs.isNull()) {\n                    // immediately write and load `<fileName>-actual.pcf`\n                    // so that we can generate deep link with correct line number for each\n                    // mismatch\n                    writeExampleOutputs(actualOutputFile, examples);\n                    actualExampleOutputs.set(loadExampleOutputs(actualOutputFile));\n                  }\n\n                  var expectedMember = VmUtils.findMember(expectedGroup, exampleIndex);\n                  assert expectedMember != null;\n\n                  var actualGroup =\n                      (VmObjectLike) VmUtils.readMemberOrNull(actualExampleOutputs.get(), groupKey);\n                  var actualMember =\n                      actualGroup == null ? null : VmUtils.findMember(actualGroup, exampleIndex);\n                  if (actualMember == null) {\n                    // file was written earlier in this method;\n                    // must have been tampered with by another process\n                    throw new VmExceptionBuilder()\n                        .evalError(\"invalidOutputFileStructure\", actualOutputFile)\n                        .build();\n                  }\n\n                  testResultBuilder.addFailure(\n                      exampleFailure(\n                          getDisplayUri(exampleMember),\n                          getDisplayUri(expectedMember),\n                          expectedValuePcf,\n                          getDisplayUri(actualMember),\n                          exampleValuePcf,\n                          testResultBuilder.getCount()));\n                } else {\n                  testResultBuilder.addSuccess();\n                }\n\n                return true;\n              }));","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/runtime/TestRunner.java#L236-L272","documentation":"While validating example outputs, `doRunAndValidateExamples` re-loads the `*-actual.pcf` file it wrote earlier in the same run. If a group or example member that was just written is missing from that file, the file must have been modified or replaced by another process between the write and the read, so the runner throws `invalidOutputFileStructure` naming the actual-output file.","triggerScenarios":"Another process edits, truncates, locks, or deletes the `*-actual.pcf` file between the write and the re-read during a `pkl test` run; a file watcher or formatter rewrites the file mid-test.","commonSituations":"An auto-formatter or linter hook reformatting generated Pcf files on save; parallel test runs sharing one directory and clobbering each other's actual-output files; sync clients reverting files.","solutions":["Stop concurrent processes (formatters, watchers, parallel runs) from touching `*-actual.pcf` during the test run.","Ensure only one `pkl test` process runs against the same module/directory at a time.","Rerun the test on a clean checkout to rule out a transient clobber.","Exclude generated `*-actual.pcf`/`*-expected.pcf` files from auto-format/autosave tooling."],"exampleFix":"// before: two parallel jobs test the same module in one shared dir\n// after: give each job its own copy\nmkdir -p \"$RUNNER_TEMP/test-${CI_JOB_ID}\"\ncp -r . \"$RUNNER_TEMP/test-${CI_JOB_ID}\" && pkl test MyTest.pkl # inside the isolated copy","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (EvalError e) {\n  if (e.getMessage().contains(\"invalidOutputFileStructure\")) {\n    // rerun test; if it recurs, hunt for concurrent writers\n  }\n}","preventionTips":["Run one `pkl test` per module directory at a time.","Disable auto-formatters/linters on generated *-pcf files during test runs.","Isolate parallel CI jobs into separate working copies."],"tags":["pkl","testing","concurrency","filesystem"],"backgroundTag":"unexpected-api-response-shape","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"}