Skip to content

[lint-monster] Check scanner errors after iteration - #78574

Closed
github-actions[bot] wants to merge 1 commit into
mainfrom
codex/lintmonster-scanner-errors-ecd6044c749dd5a2
Closed

github-actions[bot] wants to merge 1 commit into
mainfrom
codex/lintmonster-scanner-errors-ecd6044c749dd5a2

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Evidence

The pre-check lint output reported 7 scanner loops without an Err() check across 6 Go source files. The complete open-issue inventory was empty, and open-PR searches found no matching implementation work.

Changes

  • Return scanner errors from Markdown extraction, include processing, remote include fetching, and zizmor parsing.
  • Raise the buffer limit for in-memory Markdown and eval scanners so long lines do not stop later directives or records from being read.
  • Log scanner failures in the result-only helper APIs and add a regression test for oversized Markdown lines.

Validation

  • make fmt passed.
  • go test ./pkg/parser -count=1 passed.
  • Focused CLI tests for eval results, imports/includes, and zizmor parsing passed.
  • make golint-custom ran; all 7 scanner findings cleared. It still exits nonzero for other findings: 1,406 indexing, 724 ignored-results, 296 long functions in pkg/cli and pkg/workflow, and 533 other findings.
  • go test ./pkg/cli -count=1 failed. Its output included gh workflow list failing because the supplied GitHub CLI is unauthenticated; the focused CLI tests above passed.

Generated by 🧌 LintMonster · codex · gpt60 · ~10 AIC · ⌖ ~1 AIC · ⊞ 17.2K · ◷

@github-actions github-actions Bot added automation cookie Issue Monster Loves Cookies! lint labels Nov 17, 2026
@pelikhan
pelikhan marked this pull request as ready for review November 17, 2026 03:05
Copilot AI adaptive review requested due to automatic review settings November 17, 2026 03:05
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

🧪 Test quality analysis by Test Quality Sentinel · copilot · routed: haiku55 xhigh · ~1 AIC · ⌖ ~2 AIC · ⊞ 7.2K · ◷

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ PR Code Quality Reviewer completed the code quality review.

PR Code Quality Reviewer

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt56 · ~4 AIC · ⌖ ~1 AIC · ⊞ 1.5K · ◷

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Ponytail Reviewer completed successfully!

Generated by Ponytail Reviewer for #78574 · codex · routed: gpt61 medium · ~5 AIC · ⌖ ~1 AIC · ⊞ 185 · ◷

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~7 AIC · ⌖ ~2 AIC · ⊞ 6.6K · ◷

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ PR Specification Reviewer completed successfully!

PR Specification Reviewer

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated by PR Specification Reviewer for #78574 · copilot · gpt56 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.6K · ◷

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What this change does: It reports scanner errors and permits long lines in two in-memory inputs. I reviewed the changed code and its callers as local CLI operations.

Should fix

  1. Use line iterators for in-memory inputs

    • What this is: Two functions scan data already held in memory.
    • Problem: They add buffer setup and error branches that cannot be reached with their readers and buffer limits.
    • Fix: Use bytes.Lines and strings.Lines; both callers already trim each line.
    • If we skip it: Extra setup and error handling remain to be maintained.

Verdict: Ship.

Lean: -17 lines possible.

Generated by ✂️ Ponytail Reviewer for #78574 · codex · routed: gpt61 medium · ~5 AIC · ⌖ ~1 AIC · ⊞ 185
Comment /ponytail to run again

}
scanner := bufio.NewScanner(bytes.NewReader(data))
// Eval answers can exceed Scanner's default 64 KiB token limit.
scanner.Buffer(make([]byte, 0, 64*1024), max(64*1024, len(data)+1))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should fix: Use bytes.Lines(data) here and strings.Lines(content) in ExtractBodyLevelImportPaths: both inputs are already in memory and each line is trimmed, so these iterators handle long lines without a buffer or an unreachable scanner-error branch. This also removes the new logger and about 17 lines of setup and error handling.

@github-actions

Copy link
Copy Markdown
Contributor Author

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-11-17T03:08:31Z
review_event: REQUEST_CHANGES
top_themes:
  - inconsistent Scanner buffer limits cause oversized content failures
  - zizmor discards valid stdout findings on stderr scan errors
  - remote include processing can leave partial results
files_reviewed:
  - pkg/cli/experiments_fetch.go
  - pkg/cli/imports.go
  - pkg/cli/includes.go
  - pkg/cli/zizmor.go
  - pkg/parser/frontmatter_content.go
  - pkg/parser/frontmatter_extraction_test.go
  - pkg/parser/include_expander.go
comment_count: 5
History

Note

This comment is managed by comment memory.

Expand the saved memory block to view or edit the persistent context for this thread.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~4 AIC · ⌖ ~1 AIC · ⊞ 1.5K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found correctness regressions in scanner handling. Five paths now turn ordinary oversized markdown/log lines into hard failures or partial operations, and zizmor can discard valid stdout findings when stderr exceeds Scanner's limit. Please raise buffers consistently and preserve valid output before merging.

Highlights
  • zizmor parsing aborts before valid findings are decoded.
  • Include and section processing reject large content without the buffer increases used elsewhere.
  • Remote include fetching can stop after partial writes in non-strict mode.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~4 AIC · ⌖ ~1 AIC · ⊞ 1.5K
Comment /review to run again

Comment thread pkg/cli/zizmor.go
}
}
}
if err := scanner.Err(); err != nil {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new error return can discard valid zizmor findings whenever stderr contains a line over Scanner's 64 KiB limit.

💡 Preserve stdout findings

The stdout JSON is parsed only after this check, so an oversized informational stderr line turns an otherwise valid audit into a parse failure. Raise the scanner buffer (or log the stderr scan error and continue parsing stdout) and add a regression test with a long stderr line plus valid JSON findings.

Comment thread pkg/cli/imports.go
queue = append(queue, nestedFilePath)
}
}
if err := nestedScanner.Err(); err != nil {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds a hard failure for any included markdown line over 64 KiB, but unlike the other in-memory scanners in this PR it does not raise the buffer limit.

💡 Avoid rejecting valid includes

A long line in an included document now aborts processing before nested directives are discovered, changing a previously successful include into an error. Configure nestedScanner.Buffer with a limit derived from markdownContent (and test a long line followed by a nested include) so the scanner-error check reports genuine failures rather than normal large content.

Comment thread pkg/cli/includes.go
}
}
}
if err := scanner.Err(); err != nil {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This returns after a default Scanner error without increasing the buffer, so one oversized line can silently prevent all later remote includes from being fetched in non-strict mode.

💡 Keep scanning valid workflow content

The caller treats this as a warning when strict mode is disabled, leaving a partially fetched dependency set while reporting success; strict mode can also fail after earlier files were written. Raise the scanner buffer based on content length (and cover a long line followed by an include) so ordinary large markdown does not trigger this partial-operation path.

sectionContent.WriteString(line + "\n")
}
}
if err := scanner.Err(); err != nil {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new check makes any markdown section containing a line over 64 KiB fail, because this scanner still uses the default token limit.

💡 Do not turn large content into compilation failures

Sections can legitimately contain generated tables or embedded data, and callers use this helper for include/import extraction. Raise the buffer limit from len(content), as done for the eval scanner, before treating ErrTooLong as an error; add coverage for a long section line and a later header.

}
}

if err := scanner.Err(); err != nil {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds a hard scanner failure for oversized workflow lines without increasing the scanner buffer, so frontmatter extraction now rejects content that previously passed.

💡 Match the long-line handling above

A long non-directive line before an import can make expansion return an error and block compilation. Configure this scanner with a limit derived from len(content), consistent with ExtractBodyLevelImportPaths, then retain the Err check for genuine failures.

@github-actions

Copy link
Copy Markdown
Contributor Author

Comment Memory

Peek at saved memory (spec-review-history)
{"id":"ldg-ada180c5-7d2a-4a9e-a9c6-a8aea3b9f2eb","parents":[],"payload":{"id":"ldg-fd64bdb6-00bd-4032-a963-4f91793387f3","operation":"append","value":{"finding_count":0,"head_sha":"4b7b2bcbdd5cf8f2ca40ffda93b60c56a72e4c93","outcome":"aligned"}},"sha":"sha256:25f1d43fd1d270683bedfd6045caa4cf32724717e64b7f48674ec3eb18729988","timestamp":"2026-11-17T03:13:10.948Z","type":"ledger_append","version":1}
History

@github-actions

Copy link
Copy Markdown
Contributor Author

Comment Memory

Peek at saved memory (review-history)
{"id":"ldg-ba454c59-b758-4db1-9f9b-5f2c79f8f4ca","parents":[],"payload":{"id":"ldg-261c90ab-f5ee-4856-9f13-cd1ebde1b454","operation":"append","value":{"finding_count":5,"head_sha":"4b7b2bcbdd5cf8f2ca40ffda93b60c56a72e4c93","outcome":"findings"}},"sha":"sha256:588a19ccf465f06f2d767fa57d827fb7e6d8b2de3341e4d0e45414ca85081f4c","timestamp":"2026-11-17T03:13:46.195Z","type":"ledger_append","version":1}
History

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /diagnosing-bugs, /tdd, and /codebase-design. Requesting changes because the new Err() checks turn a silent truncation into a hard failure, and one of those paths runs during compilation.

📋 Key Themes & Highlights

Key Themes

  • Long-line regression: ExpandIncludesForSafeOutputs (called from compiler_orchestrator_workflow.go:654) and ExtractMarkdownSection now fail on any line over 64 KiB. Their scanners have no Buffer call. I reproduced this with a 70 KiB line, then deleted the temporary test.
  • Buffer policy: max(64*1024, len(content)+1) has no real per-line cap. Use a fixed, shared limit.
  • Error policy: result-only helpers log and return nil, while sibling sites return errors. Document the best-effort contract or make it consistent.
  • Test coverage: only the error path is tested. The long-line success path is not.

Positive Highlights

  • ✅ Consistent scanner.Err() checks across the affected per-file scanners
  • ✅ ExtractBodyLevelImportPaths and parseEvalResultRecords already raise the buffer
  • ✅ Zizmor error propagation falls back to raw output cleanly
  • ✅ imports.go:559 already checked Err() before this PR

Not Verified

  • I did not run the full pkg/parser suite after the probe.
  • I did not check whether any production workflow has a line over 64 KiB.

@copilot please address the review comments above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~7 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again

sectionContent.WriteString(line + "\n")
}
}
if err := scanner.Err(); err != nil {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/diagnosing-bugs] This Err() check now hard-fails ExtractMarkdownSection on any line over 64 KiB. Before this PR that case truncated silently. The scanner at line 248 has no Buffer call, so a long prose line inside an imported section will now break the import. Raise the buffer the way ExtractBodyLevelImportPaths does, or document the intended limit.

💡 Suggested fix
scanner := bufio.NewScanner(strings.NewReader(content))
scanner.Buffer(make([]byte, 0, 64*1024), max(64*1024, len(content)+1))

A regression test with a long line followed by a section header would lock this in.

@copilot please address this.

}
}

if err := scanner.Err(); err != nil {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/diagnosing-bugs] Same regression as ExtractMarkdownSection. The scanner at line 285 has no Buffer call, so ExpandIncludesForSafeOutputs now returns token too long for any workflow with an @include and a line over 64 KiB. This path is called from the compiler at compiler_orchestrator_workflow.go:654, so this is a compile-time break, not only a CLI warning. I reproduced it with a 70 KiB line in a temporary test, which I then deleted. Please raise the buffer here too and add a regression test.

@copilot please address this.

var results []BodyLevelImport
scanner := bufio.NewScanner(strings.NewReader(content))
// A long markdown line should not prevent directives on later lines from being found.
scanner.Buffer(make([]byte, 0, 64*1024), max(64*1024, len(content)+1))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/codebase-design] max(64*1024, len(content)+1) ties the limit to input size, so there is effectively no per-line cap. Other scanners in this repo use a fixed cap such as 1024*1024. A bounded limit gives a clear failure mode for pathological input. Consider a shared constant, for example maxIncludeLineBytes, used at every site this PR touches.

@copilot please address this.

Optional: false, // optional directives are skipped above; only required imports are promoted
})
}
if err := scanner.Err(); err != nil {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/codebase-design] This path logs and returns nil on a scan error, while the sibling changes return the error. Callers of ExtractBodyLevelImportPaths receive no signal that the result is partial. The PR body says this is intentional, so either document the best-effort contract in the function comment or change the signature to return an error.

@copilot please address this.

}
}

func TestExtractMarkdownSectionReturnsScannerError(t *testing.T) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] This test covers only the error path. Nothing exercises the success path for lines over 64 KiB, which is the behavior this PR changes. Add a case where a long line precedes a valid @import directive, and assert the directive is still found. The same gap applies to ExtractBodyLevelImportPaths and parseEvalResultRecords.

💡 Suggested test
long := strings.Repeat("x", 70*1024)
content := long + "\n@import shared.md\n"
// assert the import directive is still returned

@copilot please address this.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The runtime-import and eval-parser buffer changes lack targeted regression tests for inputs over 64 KiB, leaving dependency omissions and lost eval records unprotected against recurrence.

2 open issues
What changed in this PR

This PR improves scanner error handling in gh-aw’s Markdown, include, eval-result, and zizmor parsing paths, preventing silent truncation from being treated as success.

Changes:

  • Propagate scanner errors from APIs that return errors and log failures in result-only helpers.
  • Increase scanner limits for body-level runtime imports and eval records to support long lines.
  • Add a regression test for oversized-line errors during Markdown section extraction.
File Description
pkg/​parser/​include_expander.go Support long runtime-import lines and handle include scanner errors.
pkg/​parser/​frontmatter_extraction_test.go Test scanner error propagation for oversized Markdown lines.
pkg/​parser/​frontmatter_content.go Return Markdown section scanner errors.
pkg/​cli/​zizmor.go Return errors encountered while scanning zizmor stderr.
pkg/​cli/​includes.go Propagate remote-include scanner errors.
pkg/​cli/​imports.go Propagate nested-include scanner errors with source context.
pkg/​cli/​experiments_fetch.go Support large eval records and log scanner failures.

Review effort: Balanced (adaptive)

}
scanner := bufio.NewScanner(bytes.NewReader(data))
// Eval answers can exceed Scanner's default 64 KiB token limit.
scanner.Buffer(make([]byte, 0, 64*1024), max(64*1024, len(data)+1))
var results []BodyLevelImport
scanner := bufio.NewScanner(strings.NewReader(content))
// A long markdown line should not prevent directives on later lines from being found.
scanner.Buffer(make([]byte, 0, 64*1024), max(64*1024, len(content)+1))
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (pkg/cli/experiments_fetch.go:94): address unresolved feedback - Review comment
  3. Review (pkg/parser/include_expander.go:175): address unresolved feedback - Review comment

Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering.

Structured data
{
  "completed_task": 0,
  "head": "4b7b2bcbdd5cf8f2ca40ffda93b60c56a72e4c93",
  "kind": "requested",
  "schema_version": "1",
  "state": "3b33c93dc46a6179747767c5ab063ab50ded7ec24b04fe7fce3916a84f26e841",
  "work": [
    "652e72990f7b790c7c48731764eab059ea26d3ac854eaf2e574706c5b3927127",
    "8200d24c688ab9561b943e11ef835ea8bcbdcdf0c6d9298047a86361b4f31f05"
  ],
  "workflow": "pr-sous-chef"
}

Generated by 👨🍳 PR Sous Chef · pi · routed: haiku55 xhigh · ~2 AIC · ⌖ ~2 AIC · ⊞ 7K · ◷
Comment /souschef to run again

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

Labels

automation cookie Issue Monster Loves Cookies! lint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants