Skip to content

Invalid JSON in CodeQL action models #23147

Not planned
Not planned

Description

@woodruffw

Description of the issue

I figured I'd open a new issue for this, since the introducing PR (#23099) was already closed.

TL;DR: #23099 switched the CodeQL actions model definitions from YAML to JSON, but in the process produced what appear to be some invalid JSON files. In particular, some of the files contain //-style comments, which are not valid in JSON. Consequently, parsers like Python's json.loads fail/reject these model files instead of parsing them.

This is unfortunate for downstream consumers (like me), since the workaround is to use a JSON5 or other parser that claims support for comments. But this too is imprecise, since JSON5 is a much larger specification than just "JSON with comments" and there's no indication in the repo that the files were intended to be parsed as JSON5.

Expected behavior

The .json files in this repo would ideally be parseable with an RFC 8259 JSON parser.

Actual behavior

Some of the .json files in this repo contain invalid JSON.

Example:

// workflow_call receives the same event payload as the calling workflow

Activity

  1. jketema commented on Nov 17, 2026

    @jketema
    Contributor

    Hi @woodruffw,

    Thanks for your input. We use Jackson to parse JSON files, and Jackson allows for comments in these files. Disallowing comments would in certain instances significantly reduce the readability of these files. I will check internally, but I do not think we want to start disallowing comments.

  2. woodruffw commented on Nov 17, 2026

    @woodruffw
    Author

    Hi @jketema, thanks for your response.

    Wanting to retain the context makes sense. Would it be possible to switch to a compatible form, like writing comments as valid JSON keys?

    For example:

    "//": "comment here"

    (This is arguably a hack, but I would argue that relying on non-standard JSON parsing is also a hack 🙂)

  3. jketema commented on Nov 17, 2026

    @jketema
    Contributor

    I checked internally, and it was a deliberate decision to allow comments, so we prefer not to backtrack on this.

    It's also not clear to us what your use case is, but if this is unrelated to CodeQL we cannot offer support on this.

  4. woodruffw commented on Nov 17, 2026

    @woodruffw
    Author

    I maintain a tool, zizmor, that consumes CodeQL's data models for its own analysis. Previously I was extracting those from the YAML, and I noticed with the JSON change that the new files weren't actually valid JSON. I can work around that with a JSON5 parser, but I wasn't sure if it was intentional given the .json suffix.

    Please feel free to close this if it's not planned/not something that can be considered. I was just hopeful it was an oversight, since doing non-standard grammar things isn't great from a langsec perspective.

  5. jketema commented on Nov 17, 2026

    @jketema
    Contributor

    In that case, I'm closing this, as this was a deliberate choice.

  6. miketheman commented on Nov 17, 2026

    @miketheman

    @jketema Thanks for clarifying that it was a deliberate choice, could I ask that the file writers add the JSONC designation inline, as the JSONC spec advises, since the filenames are unlikely to be changed to .jsonc extension.

    Having that marker allows tools to make a determination about the contents might be a low-effort solution?

  7. jketema commented on Nov 17, 2026

    @jketema
    Contributor

    Hi @miketheman

    I think that's a solution that's very error prone, as as adding that inline is easily forgotten unless we add CI checks for this, which adds a maintenance burden.

  8. miketheman commented on Nov 17, 2026

    @miketheman

    I hear you, I do. Instead, shifting the burden on to downstream JSON parsers feels ... wrong to me.

    But it's your project.

  9. jketema commented on Nov 17, 2026

    @jketema
    Contributor

    Our assumption is that these files will only every be used by CodeQL, and not by what seems - effectively - a competing product.

  10. woodruffw commented on Nov 17, 2026

    @woodruffw
    Author

    Just for clarity: zizmor is not a product (it's my personal side project), and GitHub is both a sponsor and user of it. I've talked and worked on-and-off with various CodeQL folks for years and have been a corporate paying user of it (including well before GitHub bought Semmle). So I don't really see the two as competing.

    (For example, this repo itself uses zizmor here.)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions