Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recreated bug with lineObjects being corrupted due to not accounting for $ref line numbers #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lobocv
Copy link

@lobocv lobocv commented Oct 11, 2024

This is a PR that recreates the issue with a test
See the discussion of the original issue in vacuum.

TLDR: The doctor uses a data structure that maps line numbers to YAML objects, however the line numbers do not account for $ref, in particular, $ref to other YAML files. This causes multiple YAML objects to be mapped to the same line number, but the code only records the first object to come in from the concurrent processing of objects.

This results in non-deterministic results of the $path in the vacuum report and causes issues for people using that $path in ignore files.

I'm happy to help fix this but would need guidance on the best approach as I think it's not straight forward.

@daveshanley
Copy link
Member

I think the key here is to change lineObjects to be a different design that encapsulates all mappings. We can then determine which path is correct based on the parent.

@daveshanley
Copy link
Member

I am probably going to end up touching this code soon as I move the doctor into the next phase of its life with a new update that is coming soon.

@lobocv
Copy link
Author

lobocv commented Oct 18, 2024

Excellent, then I'll hold off on exploring this further. The problem is well understood but the solution is challenging for me.

One more thing to consider when you come up with a solution. A line number may contain two parts (key and value). Right now I don't think lineObjects accounts for this. I think it always holds the value, but this is an issue for linting rules that run against the key. It can be solved by making the lineObjects map's value a tuple of (left, right) or something of the like

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.

2 participants