{"record":{"id":"a30bfa57af0c3cb5","repo":"louislam/dockge","slug":"invalid-env-format","errorCode":null,"errorMessage":"Invalid .env format","messagePattern":"Invalid \\.env format","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"backend/stack.ts","lineNumber":129,"sourceCode":"        return this._status;\n    }\n\n    validate() {\n        // Check name, allows [a-z][0-9] _ - only\n        if (!this.name.match(/^[a-z0-9_-]+$/)) {\n            throw new ValidationError(\"Stack name can only contain [a-z][0-9] _ - only\");\n        }\n\n        // Check YAML format\n        yaml.parse(this.composeYAML);\n\n        let lines = this.composeENV.split(\"\\n\");\n\n        // Check if the .env is able to pass docker-compose\n        // Prevent \"setenv: The parameter is incorrect\"\n        // It only happens when there is one line and it doesn't contain \"=\"\n        if (lines.length === 1 && !lines[0].includes(\"=\") && lines[0].length > 0) {\n            throw new ValidationError(\"Invalid .env format\");\n        }\n    }\n\n    get composeYAML() : string {\n        if (this._composeYAML === undefined) {\n            try {\n                this._composeYAML = fs.readFileSync(path.join(this.path, this._composeFileName), \"utf-8\");\n            } catch (e) {\n                this._composeYAML = \"\";\n            }\n        }\n        return this._composeYAML;\n    }\n\n    get composeENV() : string {\n        if (this._composeENV === undefined) {\n            try {\n                this._composeENV = fs.readFileSync(path.join(this.path, \".env\"), \"utf-8\");","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/louislam/dockge/blob/f809ae192b571944ad773e9866d3e67064ae8043/backend/stack.ts#L111-L147","documentation":"After parsing the compose YAML, Stack.validate() checks composeENV: docker-compose rejects a single-line .env that has no '=' (it triggers 'setenv: The parameter is incorrect'). A non-empty single line lacking '=' therefore throws this ValidationError to fail fast with a clearer message.","triggerScenarios":"Saving a stack where composeENV is exactly one non-empty line that contains no '=', e.g. 'DEBUG' or 'just some text'. Multi-line values or lines with '=' pass this check.","commonSituations":"Pasting a bare variable name without its value; trailing newline removed so lines.length === 1; writing a comment or note into the .env editor.","solutions":["Format the .env line as KEY=value, e.g. 'DEBUG=true'.","Remove the stray line if no env var is needed (empty string is allowed).","Add a second line or trailing newline only if it is a valid KEY=value pair; the validation only rejects the single-line no-'=' case."],"exampleFix":"// before\nstack.composeENV = 'DEBUG';\nstack.save();\n// after\nstack.composeENV = 'DEBUG=true';\nstack.save();","handlingStrategy":"validation","validationCode":"function isValidEnvContent(env) {\n    if (typeof env !== 'string') return false;\n    const lines = env.split('\\n');\n    return !(lines.length === 1 && lines[0].length > 0 && !lines[0].includes('='));\n}","typeGuard":null,"tryCatchPattern":"try {\n    stack.save();\n} catch (e) {\n    if (e.message.includes('.env')) {\n        e.message = 'Each .env line must be KEY=value';\n        throw e;\n    }\n}","preventionTips":["Write .env entries strictly as KEY=value pairs","Never leave a bare variable name or free-text line as the only line","Preview/paste env content through a KEY=value linter before saving"],"tags":["validation","env","docker-compose","stack"],"backgroundTag":"invalid-env-format","analyzedSha":"f809ae192b571944ad773e9866d3e67064ae8043","analyzedAt":"2026-08-31T19:13:50.919Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}