Skip to content

fix(schema): report example parsing errors in TestValidateConfigExample#211

Open
G26karthik wants to merge 1 commit into
modelpack:mainfrom
G26karthik:fix-example-test-error-reporting
Open

fix(schema): report example parsing errors in TestValidateConfigExample#211
G26karthik wants to merge 1 commit into
modelpack:mainfrom
G26karthik:fix-example-test-error-reporting

Conversation

@G26karthik
Copy link
Copy Markdown

Fixes #210

Summary

TestValidateConfigExample was using the wrong error variable when reporting per-example parse failures, so example parsing errors were silently ignored instead of failing the test.

Details

  • Problem: Inside the example loop in schema/example_test.go, example.Err is checked, but t.Error(err) is called. err is the result of extractExamples(...) from earlier in the function and is nil once the loop runs, so t.Error(nil) is a no-op. Any malformed example in docs/config.md passes the test silently.
  • Fix: Pass example.Err to t.Error, matching the variable that was just checked one line above. One-character variable name change, no logic change.
  • Tests: This is itself a test fix. Verified the change does not regress any existing case (go test ./schema -v passes). Manually injecting a malformed example into docs/config.md now correctly fails the test, where it previously passed.

Testing

go test ./schema -v          # all tests pass

The validate() function used t.Error(err) where err was the result of
extractExamples from an earlier scope. When extractExamples succeeded,
err was nil, so t.Error(nil) was a no-op. This caused example parsing
failures to be silently ignored rather than failing the test.

Use example.Err instead so each example's actual parsing error is
reported as a test failure.

Signed-off-by: G26Karthik <karthik26092005@gmail.com>
Copilot AI review requested due to automatic review settings May 13, 2026 16:40
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes TestValidateConfigExample so that per-example parsing failures from docs/config.md are correctly reported and cause the test to fail, rather than being silently ignored due to logging the wrong error variable.

Changes:

  • In schema/example_test.go, report example.Err (the per-example parse error) instead of the earlier err value from extractExamples(...).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@G26karthik G26karthik closed this May 13, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request fixes a bug in schema/example_test.go where the incorrect variable was passed to t.Error. The reviewer recommends refactoring the error logging to use t.Errorf to avoid duplicate log entries, which would improve code conciseness and consistency.

Comment thread schema/example_test.go
@G26karthik G26karthik reopened this May 13, 2026
@G26karthik
Copy link
Copy Markdown
Author

Hi maintainers - flagging that the pr-labels check is failing because external contributors cannot apply labels themselves. Suggested label for this PR: bug (it fixes a silent test-failure path; matches the bug label on related schema fix #170). Could a maintainer apply it when convenient? Happy to address any review comments. Thanks!

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.

TestValidateConfigExample silently swallows example parsing errors

2 participants