advanced-security / set-codeql-language-matrix

Automatically set the CodeQL matrix job using the languages in your repository.
MIT License
11 stars 7 forks source link

Issue with v1.1.0 #5

Closed gurucloudsec closed 4 months ago

gurucloudsec commented 1 year ago

The most recent change in v1.1.0 of this action results in a JSON parsing error. I have cloned the action and did some troubleshooting. I was able to resolve the issue by removing the string value from the set_action_output function.

Its related to this most recent change;

print("Detected languages: {0}={1}".format(output_name, value), file=f)

The string value of "Detected languages" is causing the issue when its written to GITHUB_OUTPUT causing a null value to be entered. When the workflow file calls ${{ fromJSON(needs.create-matrix.outputs.matrix) }} it results in a JSON parsing error.

Suggest removing detected languages string and revert back to the v1.0 print statement. Given detected languages are already printed to Github console from "Get Languages from Repo" step I feel its redundant to write "Detected Langugages:" to GITHUB_OUTPUT as well. This resolved the issue for us.

def set_action_output(output_name, value) :
    if "GITHUB_OUTPUT" in os.environ :
        with open(os.environ["GITHUB_OUTPUT"], "a") as f :
            print("{0}={1}".format(output_name, value), file=f)

image

Thank you for the great work creating this action!

LeShadow commented 5 months ago

@gurucloudsec

I opened a PR with your proposed fix.

LeShadow commented 4 months ago

@gurucloudsec it seems that the PR I created, with your proposed fix, got merged!