Skip to content

[BUG] Requirement Validation Fails When Metadata Fields Precede Description #418

Closed

Description

@harikrishnan83

The requirement SHALL/MUST validation incorrectly checks metadata fields instead of the requirement description, causing false validation failures on valid requirements.

Steps to Reproduce

  • Create a spec file with a requirement that includes metadata fields immediately after the title:
    ### Requirement: File Serving
    **ID**: REQ-FILE-001
    **Priority**: P1
    
    The system MUST serve static files from the root directory.
    
  • Run validation on the spec file
  • Observe validation failure despite the requirement containing proper normative keywords (MUST)

Expected Behavior

The validator should:

  • Skip metadata field lines (matching pattern /^\*\*[^*]+\*\*:/)
  • Check the actual requirement description for SHALL/MUST keywords
  • Pass validation since the description contains "MUST"

Actual Behavior

The validator:

  • Extracts the first non-empty line after the requirement header
  • Returns ID: REQ-FILE-001 as the "requirement text"
  • Fails validation because this metadata field doesn't contain SHALL/MUST
  • Ignores the actual requirement description

Root Cause

The extractRequirementText() method in src/core/validation/validator.ts collects all lines after the requirement header, joins them, and returns the first non-empty line. It doesn't skip metadata field lines before extracting the normative description.

Impact

  • Severity: Medium-High
  • Users cannot use metadata fields in requirements without triggering false validation failures
  • Blocks adoption of structured requirement metadata
  • Valid, well-formed requirements are incorrectly flagged as invalid
  • No workaround exists other than removing metadata fields or placing them after the description

Environment

  • Affected component: cli-validate spec
  • File: src/core/validation/validator.ts
  • Method: extractRequirementText()

Activity

  1. coderabbitai commented on Dec 29, 2025

    @coderabbitai
    Contributor

    📝 CodeRabbit Plan Mode

    Generate an implementation plan and prompts that you can use with your favorite coding agent.

    • Create Plan
    Examples

    🔗 Similar Issues

    Possible Duplicates

    Related Issues

    👤 Suggested Assignees

    🧪 Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

  2. harikrishnan83 commented on Dec 29, 2025

    @harikrishnan83
    ContributorAuthor

    @bindoon is this what you are referring to in #356 ?

  3. harikrishnan83 commented on Dec 29, 2025

    @harikrishnan83
    ContributorAuthor

    I am still testing this issue and will close it if it is not reproducible after upgrading.

  4. clay-good commented on Jul 22, 2026

    @clay-good
    Collaborator

    Closing as fixed by #1281 (shipped in v1.6.0). The unified requirement reader (src/core/parsers/requirement-text.ts) now skips **ID**: / **Priority**: style metadata lines before looking for SHALL/MUST, so structured requirements with metadata fields validate correctly.

    Verified on current main: a requirement with metadata lines before "The system MUST..." passes, and the same spec without MUST still fails (the check itself is alive and well). Your metadata may now precede your description with a clear conscience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions