{"record":{"id":"dba64b6ecd84547e","repo":"apple/pkl","slug":"failed-to-create-an-evaluator-e","errorCode":null,"errorMessage":"Failed to create an evaluator. $e","messagePattern":"Failed to create an evaluator\\. \\$e","errorType":"exception","errorClass":"ProtocolException","httpStatus":null,"severity":"error","filePath":"pkl-server/src/main/kotlin/org/pkl/server/Server.kt","lineNumber":234,"sourceCode":"          }\n        logger = ClientLogger(evaluatorId, transport)\n        addModuleKeyFactories(createModuleKeyFactories(message, evaluatorId, resolver))\n        addResourceReaders(createResourceReaders(message, evaluatorId, resolver))\n        message.env?.let { environmentVariables = it }\n        message.properties?.let { externalProperties = it }\n        timeout = message.timeout\n        moduleCacheDir = message.cacheDir\n        message.project?.let { proj ->\n          val dependencies = buildDeclaredDependencies(proj.projectFileUri, proj.dependencies, null)\n          log(\"Got dependencies: $dependencies\")\n          setProjectDependencies(dependencies)\n        }\n        outputFormat = message.outputFormat\n        message.traceMode?.let { traceMode = it }\n        build()\n      }\n    } catch (e: IllegalArgumentException) {\n      throw ProtocolException(e.message ?: \"Failed to create an evaluator. $e\", e)\n    } catch (e: IllegalStateException) {\n      throw ProtocolException(e.message ?: \"Failed to create an evaluator. $e\", e)\n    }\n  }\n\n  private fun createResourceReaders(\n    message: CreateEvaluatorRequest,\n    evaluatorId: Long,\n    modulePathResolver: ModulePathResolver,\n  ): List<ResourceReader> = buildList {\n    add(ResourceReaders.environmentVariable())\n    add(ResourceReaders.externalProperty())\n    add(ResourceReaders.file())\n    add(ResourceReaders.http())\n    add(ResourceReaders.https())\n    add(ResourceReaders.pkg())\n    add(ResourceReaders.projectpackage())\n    add(ResourceReaders.modulePath(modulePathResolver))","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-server/src/main/kotlin/org/pkl/server/Server.kt#L216-L252","documentation":"createEvaluator builds an EvaluatorConfig via the builder; IllegalArgumentException from invalid builder inputs is converted to a ProtocolException (using e.message when present, else \"Failed to create an evaluator. $e\"). This surfaces invalid CreateEvaluatorRequest options to the client as a protocol-level failure.","triggerScenarios":"handleCreateEvaluator receiving a CreateEvaluatorRequest whose options are invalid — bad resourceReader parameters, invalid outputFormat, illegal timeout or allowedModules values causing the builder's IllegalArgumentException.","commonSituations":"Clients passing malformed resource reader specs, an unsupported/invalid output format string, or negative durations in evaluator options.","solutions":["Check the exception message for the exact invalid option and correct it in the request.","Validate outputFormat is a supported format string before creating the evaluator.","Ensure resource reader URIs and parameters are well-formed.","Confirm all numeric options (timeouts, limits) are within legal ranges."],"exampleFix":"// before\nrequest.outputFormat = \"yaml2\" // invalid format -> IAE\n// after\nrequest.outputFormat = \"yaml\"","handlingStrategy":"validation","validationCode":"require(request.outputFormat in setOf(\"json\", \"yaml\", \"pcf\", \"xml\", \"textproto\", \"plist\")) { \"Invalid outputFormat\" }\nrequest.resourceReaders.forEach { require(it.uri != null) { \"resourceReader missing uri\" } }","typeGuard":null,"tryCatchPattern":"try { client.createEvaluator(request) } catch (e: ProtocolException) { logger.error(\"Evaluator creation rejected: ${e.message}\") }","preventionTips":["Validate output formats and durations against supported values","Sanity-check resource reader specs before sending","Read the cause message to find the offending option","Test evaluator creation against the target pkl version"],"tags":["protocol","evaluator","invalid-argument"],"backgroundTag":"invalid-constructor-argument","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}