{"record":{"id":"a0ce11827dbd2369","repo":"microsoft/aspire","slug":"the-opentelemetry-agent-path-authored-configured-on-resource-a0ce11","errorCode":null,"errorMessage":"The OpenTelemetry agent path '{authored}' configured on resource '{resource.Name}' contains whitespace, which a Dockerfile COPY instruction cannot express, so it cannot be published. Move the agent to a path without spaces.","messagePattern":"The OpenTelemetry agent path '(.+?)' configured on resource '(.+?)' contains whitespace, which a Dockerfile COPY instruction cannot express, so it cannot be published\\. Move the agent to a path without spaces\\.","errorType":"exception","errorClass":"DistributedApplicationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Java/JavaDockerfileGenerator.cs","lineNumber":611,"sourceCode":"        }\n\n        // The Docker build context is the application directory, so a path that walks above it cannot be\n        // copied forward no matter how it is spelled. Say so instead of silently rewriting it.\n        if (normalized.Split('/').Any(segment => segment == \"..\"))\n        {\n            throw new DistributedApplicationException(\n                $\"The OpenTelemetry agent path '{authored}' configured on resource '{resource.Name}' \" +\n                $\"points outside the application directory, which is the Docker build context, so it cannot be \" +\n                $\"published. Use a path inside '{resource.WorkingDirectory}', or an absolute path that the base \" +\n                $\"image or a mount provides at runtime.\");\n        }\n\n        // The Dockerfile builder emits the shell form of COPY, whose arguments are separated by\n        // whitespace with no quoted form, so \"target/otel agents/javaagent.jar\" would copy two paths that\n        // do not exist. Naming the problem beats failing later inside the container build.\n        if (normalized.Any(char.IsWhiteSpace))\n        {\n            throw new DistributedApplicationException(\n                $\"The OpenTelemetry agent path '{authored}' configured on resource '{resource.Name}' \" +\n                $\"contains whitespace, which a Dockerfile COPY instruction cannot express, so it cannot be \" +\n                $\"published. Move the agent to a path without spaces.\");\n        }\n\n        agentPath = normalized;\n\n        return agentPath.Length > 0;\n    }\n\n    /// <summary>\n    /// The build-tool-specific pieces of the container build.\n    /// </summary>\n    /// <param name=\"Tool\">The build tool that produces the JAR.</param>\n    /// <param name=\"Args\">The resolved arguments passed to the build tool.</param>\n    /// <param name=\"BuildCommand\">The shell command that runs the build.</param>\n    /// <param name=\"SelectArtifactCommand\">The shell command that copies the produced JAR to a fixed path.</param>\n    /// <param name=\"ToolHome\">The container path the build tool treats as its home directory.</param>","sourceCodeStart":593,"sourceCodeEnd":629,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Java/JavaDockerfileGenerator.cs#L593-L629","documentation":"TryGetBuildProducedAgentPath rejects an OpenTelemetry agent path containing whitespace because the Dockerfile builder emits shell-form COPY whose arguments are space-separated with no quoted form; \"target/otel agents/javaagent.jar\" would copy two nonexistent paths. The generator throws at publish time instead of failing later inside the container build.","triggerScenarios":"Publishing a Java resource configured via WithOtelAgent with a path containing spaces, e.g. WithOtelAgent(\"target/otel agents/javaagent.jar\").","commonSituations":"Agent jar placed in a directory named with spaces; downloaded agent archives extracted into folders like \"New Folder\"; Windows-style directory names with spaces carried into the resource config.","solutions":["Rename the agent file/directory to remove spaces (e.g. \"otel/javaagent.jar\").","Copy the agent to a space-free relative path inside the app directory and point WithOtelAgent at it.","Update the script or pipeline that downloads the agent to use a space-free target directory."],"exampleFix":"// before\n.WithOtelAgent(\"target/otel agents/javaagent.jar\")\n// after\n.WithOtelAgent(\"target/otel/javaagent.jar\");","handlingStrategy":"validation","validationCode":"if (agentPath.Any(char.IsWhiteSpace))\n    throw new ArgumentException(\"Otel agent path must not contain whitespace; the generated Dockerfile COPY cannot express it\");","typeGuard":null,"tryCatchPattern":"try { await PublishAsync(...); } catch (DistributedApplicationException ex) when (ex.Message.Contains(\"whitespace\")) { Console.Error.WriteLine(ex.Message); return 1; }","preventionTips":["Store the agent jar in a space-free directory (e.g. otel/, not \"otel agents/\").","Configure download scripts to target space-free directories.","Validate agent paths for whitespace before publishing."],"tags":["java","docker","whitespace","opentelemetry"],"backgroundTag":"invalid-argument-format","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}