Skip to content

Fix Phase 1 warn-only checker crash on non-mapping YAML documents - #509

Draft
4444J99 wants to merge 1 commit into
mainfrom
fix/phase1-non-mapping-yaml-crash-7136504953090155234
Draft

4444J99 wants to merge 1 commit into
mainfrom
fix/phase1-non-mapping-yaml-crash-7136504953090155234

Conversation

@4444J99

@4444J99 4444J99 commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Phase 1 check now validates that top-level workflow and Dependabot YAML documents are mappings. When encountering non-mapping documents (e.g. sequences or scalars), it emits a structured yaml-parse finding without crashing.

Exact test results:

  • python3 -m unittest discover -s tests -v: Ran 687 tests in ~33s, 0 failures/errors.
  • python3 -m ges validate: {"valid": true, "controls": 95}
  • python3 -m ges compile: exited 0.

Fixes #508


PR created automatically by Jules for task 7136504953090155234 started by @4444J99

Summary by Sourcery

Handle non-mapping YAML documents safely during Phase 1 validation and report them as parse findings.

Bug Fixes:

  • Prevent Phase 1 validation from crashing on workflow or Dependabot YAML documents whose top-level value is not a mapping.
  • Report malformed or structurally invalid YAML documents as structured yaml-parse findings in both warn-only and enforce modes.

Enhancements:

  • Harden workflow and Dependabot validation against malformed job, step, update, schedule, and permissions structures.

Tests:

  • Add coverage for sequence and scalar top-level YAML documents, including warn-only and enforce behavior.

Validate that top-level YAML documents in workflows and Dependabot configuration are mappings before accessing keys. Emit a structured yaml-parse finding when top-level values are non-mapping (e.g. sequence or scalar), avoiding AttributeErrors/TypeErrors and honoring warn-only (exit 0) vs --enforce (exit 1) behavior.

Co-authored-by: 4444J99 <24796448+4444J99@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Oct 27, 2026

Copy link
Copy Markdown

Reviewer's Guide

Phase 1 now safely handles non-mapping or structurally malformed workflow and Dependabot YAML by reporting yaml-parse findings instead of crashing, while preserving enforcement semantics; regression tests cover sequence/scalar workflows and CLI exit behavior.

Flow diagram for safe Phase 1 YAML validation

flowchart TD
    A[Load workflow or Dependabot YAML] --> B{Top-level document is a mapping?}
    B -- No --> C[add yaml-parse finding]
    B -- Yes --> D{Nested structures have expected types?}
    D -- No --> E[Use safe empty defaults or skip malformed entries]
    D -- Yes --> F[Run existing Phase 1 checks]
    E --> F
    F --> G[Return findings without crashing]
Loading

File-Level Changes

Change Details Files
Make Phase 1 YAML loading and validation robust to non-mapping and malformed nested structures.
  • Preserve non-null YAML values from the loader instead of coercing all falsey values to mappings.
  • Emit structured yaml-parse findings when workflow or Dependabot documents are not top-level mappings or contain parse errors.
  • Guard jobs, job definitions, steps, updates, and schedules with type checks so malformed content is skipped without crashing.
  • Retain existing warn-only and enforce-mode behavior for reported findings.
standards/phase1/check.py
Add regression coverage for non-mapping workflow documents and their CLI behavior.
  • Cover sequence and scalar workflow YAML documents.
  • Assert deterministic yaml-parse finding locations and messages.
  • Verify warn-only exits successfully while --enforce exits with failure and no traceback.
tests/test_phase1_warn.py

Assessment against linked issues

Issue Objective Addressed Explanation
#508 Validate that workflow and Dependabot YAML documents have a mapping at the top level, and report non-mapping documents as structured findings instead of crashing. ✅
#508 Keep the checker warn-only by default for these findings, while returning failure under --enforce without a traceback. ✅
#508 Add regression coverage for sequence and scalar documents plus a valid mapping control, and preserve existing validation behavior. ✅

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Phase 1 warn-only checker crashes on non-mapping YAML documents

1 participant