{"record":{"id":"5c1bf795f4ec936c","repo":"portainer/portainer","slug":"invalid-stack-file-content-5c1bf7","errorCode":null,"errorMessage":"Invalid stack file content","messagePattern":"Invalid stack file content","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"api/http/handler/stacks/create_swarm_stack.go","lineNumber":42,"sourceCode":"\t// Swarm cluster identifier\n\tSwarmID string `example:\"jpofkc0i9uo9wtx1zesuk649w\" validate:\"required\"`\n\t// Content of the Stack file\n\tStackFileContent string `example:\"version: 3\\n services:\\n web:\\n image:nginx\" validate:\"required\"`\n\t// A list of environment variables used during stack deployment\n\tEnv []portainer.Pair\n\t// Whether the stack is from a app template\n\tFromAppTemplate bool `example:\"false\"`\n}\n\nfunc (payload *swarmStackFromFileContentPayload) Validate(r *http.Request) error {\n\tif len(payload.Name) == 0 {\n\t\treturn errors.New(\"Invalid stack name\")\n\t}\n\tif len(payload.SwarmID) == 0 {\n\t\treturn errors.New(\"Invalid Swarm ID\")\n\t}\n\tif len(payload.StackFileContent) == 0 {\n\t\treturn errors.New(\"Invalid stack file content\")\n\t}\n\treturn nil\n}\n\nfunc createStackPayloadFromSwarmFileContentPayload(name string, swarmID string, fileContent string, env []portainer.Pair, fromAppTemplate bool) stackbuilders.StackPayload {\n\treturn stackbuilders.StackPayload{\n\t\tName:             name,\n\t\tSwarmID:          swarmID,\n\t\tStackFileContent: []byte(fileContent),\n\t\tEnv:              env,\n\t\tFromAppTemplate:  fromAppTemplate,\n\t}\n}\n\n// @id StackCreateDockerSwarmString\n// @summary Deploy a new swarm stack from a text\n// @description Deploy a new stack into a Docker environment specified via the environment identifier.\n// @description **Access policy**: authenticated","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/portainer/portainer/blob/17e74456ff6e794b9d5439ec3fa06922aa18a3f8/api/http/handler/stacks/create_swarm_stack.go#L24-L60","documentation":"Error \"Invalid stack file content\" thrown in portainer/portainer.","triggerScenarios":"Thrown at api/http/handler/stacks/create_swarm_stack.go:42 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"17e74456ff6e794b9d5439ec3fa06922aa18a3f8","analyzedAt":"2026-08-26T23:09:01.915Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}