{"record":{"id":"2f6125f835b842d2","repo":"Fission-AI/OpenSpec","slug":"invalid-marker-state-in-filepath-found-start","errorCode":null,"errorMessage":"Invalid marker state in ${filePath}. Found start: ${startIndex !== -1}, Found end: ${endIndex !== -1}","messagePattern":"Invalid marker state in (.+?)\\. Found start: (.+?), Found end: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/utils/file-system.ts","lineNumber":350,"sourceCode":"      const startIndex = findMarkerIndex(existingContent, startMarker);\n      const endIndex = startIndex !== -1\n        ? findMarkerIndex(existingContent, endMarker, startIndex + startMarker.length)\n        : findMarkerIndex(existingContent, endMarker);\n\n      if (startIndex !== -1 && endIndex !== -1) {\n        if (endIndex < startIndex) {\n          throw new Error(\n            `Invalid marker state in ${filePath}. End marker appears before start marker.`\n          );\n        }\n\n        const before = existingContent.substring(0, startIndex);\n        const after = existingContent.substring(endIndex + endMarker.length);\n        existingContent = before + startMarker + '\\n' + content + '\\n' + endMarker + after;\n      } else if (startIndex === -1 && endIndex === -1) {\n        existingContent = startMarker + '\\n' + content + '\\n' + endMarker + '\\n\\n' + existingContent;\n      } else {\n        throw new Error(`Invalid marker state in ${filePath}. Found start: ${startIndex !== -1}, Found end: ${endIndex !== -1}`);\n      }\n    } else {\n      existingContent = startMarker + '\\n' + content + '\\n' + endMarker;\n    }\n    \n    await this.writeFile(filePath, existingContent);\n  }\n\n  static async ensureWritePermissions(dirPath: string): Promise<boolean> {\n    try {\n      // If directory doesn't exist, check parent directory permissions\n      if (!await this.directoryExists(dirPath)) {\n        const parentDir = path.dirname(dirPath);\n        if (!await this.directoryExists(parentDir)) {\n          await this.createDirectory(parentDir);\n        }\n        return await this.ensureWritePermissions(parentDir);\n      }","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/Fission-AI/OpenSpec/blob/6926ccb18afa4ff621112813e9968334576ee11a/src/utils/file-system.ts#L332-L368","documentation":"Error \"Invalid marker state in ${filePath}. Found start: ${startIndex !== -1}, Found end: ${endIndex !== -1}\" thrown in Fission-AI/OpenSpec.","triggerScenarios":"Thrown at src/utils/file-system.ts:350 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":"6926ccb18afa4ff621112813e9968334576ee11a","analyzedAt":"2026-08-25T12:29:45.729Z","schemaVersion":2},"datasetVersion":"2026-08-25T16:17:27.014Z"}