Skip to content

Conversation

@akhil-rasheed
Copy link

Closes #141

Addresses following comments left on the original (abandoned) PR here #164

  • Moves PKL binary validation to the pkl validator
  • Ensures we don't run into race conditions during testing by using a mutex lock
  • Adds a more complete example for good.pkl
  • Alphabetises list of supported config filetypes

olunusib and others added 10 commits August 20, 2024 21:58
The existing test for ignoring PKL files when the binary is missing was not safe for parallel execution, as it modified a global function variable, creating a data race condition.

This commit resolves the issue by refactoring the validation logic:

1. The responsibility for checking for the pkl binary is moved from the CLI into the `PklValidator`.
2. The validator now returns a specific `ErrSkipped` error if the binary is not found.
3. A thread-safe `SetPklBinaryChecker` function is introduced, allowing tests to safely mock the check.
4. The test is updated to use this new thread-safe mechanism.
- Removes a redeclared isPklBinaryPresent function that was causing a build failure.
- Updates the test logic to check for the new ErrSkipped sentinel error, aligning it with the recent refactoring.
- Removes an unused import.
- Fixes a build failure in the filetype package by using the correct `tools` import.
- Updates the `good.pkl` test fixture with valid syntax so that tests pass when the pkl binary is installed.
@akhil-rasheed akhil-rasheed marked this pull request as ready for review October 7, 2025 07:38
@kehoecj kehoecj added the waiting-on-maintainer-review PR is waiting to be reviewed and functionally tested by the maintainers label Oct 7, 2025
@kehoecj kehoecj self-requested a review October 7, 2025 13:49
@kehoecj
Copy link
Collaborator

kehoecj commented Oct 7, 2025

@akhil-rasheed Thanks for the PR! Please address the issues identified in the unit and mega linter jobs.

@kehoecj kehoecj added OSS Community Contribution Contributions from the OSS Community pr-action-requested PR is awaiting feedback from the submitting developer and removed waiting-on-maintainer-review PR is waiting to be reviewed and functionally tested by the maintainers labels Oct 7, 2025
Akhil Rasheed added 2 commits October 8, 2025 16:24
Refactors the pkl validator to improve testability and adds tests for uncovered code paths.

- Modifies the `PklValidator` to allow injecting an evaluator factory, making it easier to test error conditions.
- Adds a test to verify that `ErrSkipped` is returned when the `pkl` binary is not found.
- Adds a test to verify that an error is returned when the pkl evaluator fails to be created.
@akhil-rasheed
Copy link
Author

I've addressed the coverage issues and some whitespace in the workflow file which was causing the yaml linter to fail @kehoecj

@akhil-rasheed akhil-rasheed force-pushed the feat/pkl-validation branch 2 times, most recently from ade80f0 to 309847e Compare October 8, 2025 11:57
@kehoecj
Copy link
Collaborator

kehoecj commented Oct 8, 2025

I've addressed the coverage issues and some whitespace in the workflow file which was causing the yaml linter to fail @kehoecj

Still seeing at least one test failure: #331 (comment)

Removes `t.Parallel()` from tests that modify the global `isPklBinaryPresent`
variable. This prevents potential race conditions between tests that
rely on the state of this variable.
@akhil-rasheed
Copy link
Author

I've addressed the coverage issues and some whitespace in the workflow file which was causing the yaml linter to fail @kehoecj

Still seeing at least one test failure: #331 (comment)

Resolved

@kehoecj
Copy link
Collaborator

kehoecj commented Oct 8, 2025

I've addressed the coverage issues and some whitespace in the workflow file which was causing the yaml linter to fail @kehoecj

Still seeing at least one test failure: #331 (comment)

Resolved

Can you take another look? I'm still seeing a failure in the pipeline

@akhil-rasheed
Copy link
Author

Total Summary: 35 succeeded, 0 failed
--- FAIL: Test_TripleGroupOutput (0.11s)
=== RUN   Test_IncorrectSingleGroupOutput
--- PASS: Test_IncorrectSingleGroupOutput (0.10s)
=== RUN   Test_IncorrectDoubleGroupOutput
--- PASS: Test_IncorrectDoubleGroupOutput (0.06s)
=== RUN   Test_IncorrectTripleGroupOutput
--- PASS: Test_IncorrectTripleGroupOutput (0.07s)
FAIL
coverage: 93.2% of statements
FAIL	github.com/Boeing/config-file-validator/pkg/cli	0.781s
?   	github.com/Boeing/config-file-validator/pkg/filetype	[no test files]

This is on the CI, I assume this is where it's failing, but the same test passes for me locally

Total Summary: 35 succeeded, 0 failed
--- PASS: Test_TripleGroupOutput (0.07s)
=== RUN   Test_IncorrectSingleGroupOutput
--- PASS: Test_IncorrectSingleGroupOutput (0.06s)
=== RUN   Test_IncorrectDoubleGroupOutput
--- PASS: Test_IncorrectDoubleGroupOutput (0.07s)
=== RUN   Test_IncorrectTripleGroupOutput
--- PASS: Test_IncorrectTripleGroupOutput (0.06s)
PASS
ok  	github.com/Boeing/config-file-validator/pkg/cli	1.423s

Am I just not identifying the failure correctly?

@kehoecj
Copy link
Collaborator

kehoecj commented Oct 8, 2025

Total Summary: 35 succeeded, 0 failed
--- FAIL: Test_TripleGroupOutput (0.11s)
=== RUN   Test_IncorrectSingleGroupOutput
--- PASS: Test_IncorrectSingleGroupOutput (0.10s)
=== RUN   Test_IncorrectDoubleGroupOutput
--- PASS: Test_IncorrectDoubleGroupOutput (0.06s)
=== RUN   Test_IncorrectTripleGroupOutput
--- PASS: Test_IncorrectTripleGroupOutput (0.07s)
FAIL
coverage: 93.2% of statements
FAIL	github.com/Boeing/config-file-validator/pkg/cli	0.781s
?   	github.com/Boeing/config-file-validator/pkg/filetype	[no test files]

This is on the CI, I assume this is where it's failing, but the same test passes for me locally

Total Summary: 35 succeeded, 0 failed
--- PASS: Test_TripleGroupOutput (0.07s)
=== RUN   Test_IncorrectSingleGroupOutput
--- PASS: Test_IncorrectSingleGroupOutput (0.06s)
=== RUN   Test_IncorrectDoubleGroupOutput
--- PASS: Test_IncorrectDoubleGroupOutput (0.07s)
=== RUN   Test_IncorrectTripleGroupOutput
--- PASS: Test_IncorrectTripleGroupOutput (0.06s)
PASS
ok  	github.com/Boeing/config-file-validator/pkg/cli	1.423s

Am I just not identifying the failure correctly?

That appears to be the correct failure - let me see if it passes locally for me as well. There may be a timing issue that is present in the pipeline causing it to fail

@akhil-rasheed
Copy link
Author

I have made the changes that @ccoVeille requested. @kehoecj were you able to replicate the pipeline issue locally?

Co-authored-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com>
Copy link
Collaborator

@kehoecj kehoecj left a comment

Choose a reason for hiding this comment

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

When the PKL executable is not installed, a runtime error is generated:

> .\validator.exe .\test\                         
Warning: 'pkl' binary not found, file C:\Users\se456c\src\github.com\prs\pkl\config-file-validator\test\fixtures\good.pkl will be ignored.
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x7ff78ccb90f0]

goroutine 22 [running]:
github.com/apple/pkl-go/pkl.(*execEvaluator).deinit(0xc000206140)
        C:/Users/se456c/go/pkg/mod/github.com/apple/pkl-go@v0.8.0/pkl/evaluator_manager_exec.go:214 +0x70        
github.com/apple/pkl-go/pkl.(*evaluatorManager).closeErr(0xc000193bc0, {0x7ff78cee41c0?, 0xc000116e80?})
        C:/Users/se456c/go/pkg/mod/github.com/apple/pkl-go@v0.8.0/pkl/evaluator_manager.go:308 +0x82
github.com/apple/pkl-go/pkl.(*evaluatorManager).listenForImplClose(0xc000193bc0)
        C:/Users/se456c/go/pkg/mod/github.com/apple/pkl-go@v0.8.0/pkl/evaluator_manager.go:245 +0x46
created by github.com/apple/pkl-go/pkl.NewEvaluatorManagerWithCommand in goroutine 1
        C:/Users/se456c/go/pkg/mod/github.com/apple/pkl-go@v0.8.0/pkl/evaluator_manager_exec.go:61 +0x256

@kehoecj
Copy link
Collaborator

kehoecj commented Oct 13, 2025

I have made the changes that @ccoVeille requested. @kehoecj were you able to replicate the pipeline issue locally?

Tests are failing with the latest changes due to the runtime error

@kehoecj
Copy link
Collaborator

kehoecj commented Oct 22, 2025

@akhil-rasheed Just checking in - any questions or concerns about the last set of review comments?

@akhil-rasheed
Copy link
Author

All good, will restart work on this starting Monday

@kehoecj kehoecj added the hacktoberfest-accepted Valid PR Hacktoberfest PR label Oct 23, 2025
Use the in-process pkl-go interpreter for validation instead of requiring the pkl binary to be installed.

This simplifies usage by removing the external dependency.
@akhil-rasheed akhil-rasheed requested a review from a team as a code owner November 3, 2025 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest-accepted Valid PR Hacktoberfest PR OSS Community Contribution Contributions from the OSS Community pr-action-requested PR is awaiting feedback from the submitting developer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support PKL file

4 participants