Fission-AI/OpenSpec · error · ChangeMetadataError
Failed to write metadata
Error message
Failed to write metadata: ${ioError.message} What it means
ChangeMetadataError thrown by writeChangeMetadata inside its try/catch around fs.writeFileSync: writing the YAML metadata file failed at the OS level (permissions, missing parent directory, disk). Validation already passed; this is purely an I/O failure wrapped with the target path.
Solutions
- Check write permissions on the change directory
- Ensure the parent directory exists before writing
- Free disk space or resolve the underlying OS error in the message
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at src/utils/change-metadata.ts:78 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Fission-AI/OpenSpec@6926ccb18a (2026-08-25).
Data as JSON: /api/errors/83edb9e7babf6499.
Report an issue: GitHub.
Appendix: source
Thrown at src/utils/change-metadata.ts:78
// Validate schema exists
validateSchemaName(metadata.schema, projectRoot);
// Validate with Zod
const parseResult = ChangeMetadataSchema.safeParse(metadata);
if (!parseResult.success) {
throw new ChangeMetadataError(
`Invalid metadata: ${parseResult.error.message}`,
metaPath
);
}
// Write YAML file
const content = yaml.stringify(parseResult.data);
try {
fs.writeFileSync(metaPath, content, 'utf-8');
} catch (err) {
const ioError = err instanceof Error ? err : new Error(String(err));
throw new ChangeMetadataError(
`Failed to write metadata: ${ioError.message}`,
metaPath,
ioError
);
}
}
/**
* Reads change metadata from .openspec.yaml in the change directory.
*
* @param changeDir - The path to the change directory
* @param projectRoot - Optional project root for project-local schema resolution
* @returns The validated metadata, or null if no metadata file exists
* @throws ChangeMetadataError if the file exists but is invalid
*/
export function readChangeMetadata(
changeDir: string,
projectRoot?: stringView on GitHub (pinned to 6926ccb18a)