Fission-AI/OpenSpec · error

The --language option is too long for OpenSpec's

Error message

The --language option is too long for OpenSpec's ${MAX_CONTEXT_SIZE / 1024}KB project context limit.

What it means

Thrown by normalizeLanguage when the --language value exceeds OpenSpec's project-context size limit (MAX_CONTEXT_SIZE). The language string is stored in config.yaml as context, and an oversized value would blow the AI context budget; the error states the KB limit so the caller shortens it.

Solutions

  1. Shorten the language instruction to fit within the context limit
  2. Move lengthy instructions to documentation referenced from the config
  3. Split content across the context field more concisely
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/core/init.ts:1041 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/35f08ac8c7951ff5. Report an issue: GitHub.

Appendix: source

Thrown at src/core/init.ts:1041

  // ═══════════════════════════════════════════════════════════
  // CONFIG FILE
  // ═══════════════════════════════════════════════════════════

  private normalizeLanguage(language: string | undefined): string | undefined {
    if (language === undefined) return undefined;

    const normalized = language.trim();
    if (!normalized) {
      throw new Error('The --language option requires a non-empty value.');
    }
    if (/\p{Cc}|\p{Bidi_Control}|[\u200B\u2028\u2029\uFEFF]/u.test(normalized)) {
      throw new Error(
        'The --language option must be a single line without control or invisible formatting characters.'
      );
    }
    const serializedContext = `${formatLanguageContext(normalized)}\n`;
    if (Buffer.byteLength(serializedContext, 'utf8') > MAX_CONTEXT_SIZE) {
      throw new Error(
        `The --language option is too long for OpenSpec's ${MAX_CONTEXT_SIZE / 1024}KB project context limit.`
      );
    }
    return normalized;
  }

  private languageContext(): string | undefined {
    if (!this.language) return undefined;
    return formatLanguageContext(this.language);
  }

  private async assertLanguageCanBeApplied(
    projectPath: string,
    openspecPath: string
  ): Promise<void> {
    const languageContext = this.languageContext();
    if (!languageContext) return;

View on GitHub (pinned to 6926ccb18a)