Skip to content

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

@harikrishnan83

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()

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