Fission-AI/OpenSpec · error
Invalid 'context' field in config (must be string)
Error message
Invalid 'context' field in config (must be string)
What it means
Warning from readProjectConfig: 'context' is not a string, or exceeds MAX_CONTEXT_SIZE (in which case the size warning is emitted alongside). An invalid or oversized context field is ignored so the project still loads with defaults; the at-fault input is the raw.context YAML value.
Solutions
- Write 'context' as a single quoted YAML string
- Remove the field if no context is needed
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at src/core/project-config.ts:309 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/a07a23f06a0f9a7b.
Report an issue: GitHub.
Appendix: source
Thrown at src/core/project-config.ts:309
}
// Parse context field with size limit
if (raw.context !== undefined) {
const contextField = z.string();
const contextResult = contextField.safeParse(raw.context);
if (contextResult.success) {
const contextSize = Buffer.byteLength(contextResult.data, 'utf-8');
if (contextSize > MAX_CONTEXT_SIZE) {
console.warn(
`Context too large (${(contextSize / 1024).toFixed(1)}KB, limit: ${MAX_CONTEXT_SIZE / 1024}KB)`
);
console.warn(`Ignoring context field`);
} else {
config.context = contextResult.data;
}
} else {
console.warn(`Invalid 'context' field in config (must be string)`);
}
}
// Parse rules field using Zod
if (raw.rules !== undefined) {
const rulesField = z.record(z.string(), z.array(z.string()));
// First check if it's an object structure (guard against null since typeof null === 'object')
if (typeof raw.rules === 'object' && raw.rules !== null && !Array.isArray(raw.rules)) {
// Artifact ids are intentionally not restricted to the built-in naming
// convention, so keys such as "constructor" remain valid for custom
// schemas. A null-prototype map preserves those keys as data without
// letting "__proto__" mutate the lookup object's prototype.
const parsedRules: Record<string, string[]> = Object.create(null);
let hasValidRules = false;
for (const [artifactId, rules] of Object.entries(raw.rules)) {
const rulesArrayResult = z.array(z.string()).safeParse(rules);View on GitHub (pinned to 6926ccb18a)