Repository navigation
Conversation
You may find it surprisingly complex, but that's mainly because: - it's vibe-coded - it preserves comments - it formats the JSON so that it pretty-prints nicely, but with one line per tuple I intend to manually verify all conversions made with it.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical findings allow existing JSON files to be overwritten, temporary-file symlinks to redirect writes, and manifest matches outside the pack to cause external file writes or deletions.
3 open issues
What changed in this PR
Adds the reusable converter used in the linked model migrations, supporting CodeQL’s faster-loading JSON data extensions.
Changes:
- Converts YAML models to JSON with comment preservation and one tuple per line.
- Accepts explicit files or discovers models through a
qlpack.ymlmanifest. - Adds JSON manifest patterns while retaining YAML patterns, with optional deletion of converted sources.
| File | Description |
|---|---|
misc/scripts/convert-yaml-data-extensions-to-json.py |
Adds the conversion command, comment-aware formatting, and manifest updates. |
Review effort: Balanced (auto)
Comment on lines
+249
to
+254
| temporary = path.with_name(f".{path.name}.tmp") | ||
| try: | ||
| temporary.write_text(contents, encoding="utf-8") | ||
| temporary.replace(path) | ||
| finally: | ||
| temporary.unlink(missing_ok=True) |
|
|
||
| def convert_data_extension(source: Path, delete_yaml: bool = False) -> Path: | ||
| """Convert a YAML data extension to JSON, optionally removing the source.""" | ||
| target = source.with_suffix(".json") |
Comment on lines
+277
to
+286
| files = set() | ||
| for pattern in patterns: | ||
| if not isinstance(pattern, str): | ||
| raise ValueError(f"dataExtensions pattern is not a string: {pattern!r}") | ||
| files.update( | ||
| match.resolve() | ||
| for match in path.parent.glob(pattern.lstrip("/")) | ||
| if match.is_file() and match.suffix in {".yml", ".yaml"} | ||
| ) | ||
| return sorted(files) |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This is the script I used to perform the conversions in the PRs below. I'm adding it to the repo in case anyone else needs to convert models, here or elsewhere, in the future.
I don't particularly recommend reviewing the script itself — it was generated by Copilot and I certainly haven't. It's complicated because it preserves comments and produces a non-standard JSON formatting in order to get each tuple on one line. But it worked well enough that I was able to verify all the conversions in the PRs below, and the only manual edits required were a few tweaks to comment locations.