yuzutech / annotations-action

GitHub action to create annotations from a JSON file
MIT License
34 stars 15 forks source link

Getting a GitHubApiError when running this action #36

Open emily-hawkins opened 3 years ago

emily-hawkins commented 3 years ago

running:

      - name: Annotate
        uses: yuzutech/annotations-action@v0.3.0
        with:
          repo-token: "${{ secrets.GITHUB_TOKEN }}"
          title: 'SQLFluff Lint'
          input: './annotations.json'

the contents of the json file look like this:

[{"file": "dbt/models/admin/fact_dbt_runs.sql", "line": 7, "start_column": 1, "title": "SQLFluff", "message": "L010: Inconsistent capitalisation of keywords.", "annotation_level": "failure"}]

and this is what is returned in github actions:

Run yuzutech/annotations-action@v0.3.0
  with:
    repo-token: ***
    ignore-unauthorized-error: true
    title: SQLFluff Lint
    input: ./annotations.json
    ignore-missing-file: true
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.7.10/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.7.10/x64/lib
Creating check {owner: 'DrizlyInc', repo: 'data-workflows', name: SQLFluff Lint}
Found 1 failure(s), 0 warning(s) and 0 notice(s)
Updating check {owner: 'DrizlyInc', repo: 'data-workflows', check_run_id: 3069168367}
Error: GitHubApiError: Unable to update check {owner: 'DrizlyInc', repo: 'data-workflows', check_run_id: 3069168367} - cause: HttpError: Validation Failed: {"resource":"CheckRun","code":"invalid","field":"annotations"}

Any insight on what might be the cause of this? I have other actions that are able to annotate, though they are built into the action itself so i dont have much insight into what they might be doing differently.

emily-hawkins commented 3 years ago

Turns out there is an issue in version 0.3.0, got this to work successfully in version 0.2.1

ggrossetie commented 3 years ago

It seems that some fields are invalid.

Previously, in version 0.2.0, we were extracting some fields from the JSON file, namely:

But now, in version 0.3.0, we are using all fields from the JSON field.

Here's a valid annotation (taken from the documentation):

[
  {
    "path": "README.md",
    "start_line": 2,
    "end_line": 2,
    "start_column": 5,
    "end_column": 10,
    "annotation_level": "warning",
    "title": "Spell Checker",
    "message": "Check your spelling for 'banaas'.",
    "raw_details": "Do you mean 'bananas' or 'banana'?",
    "blob_href": "https://api.github.com/repos/github/rest-api-description/git/blobs/abc"
  }
]

I think it does not work because you didn't set both the start_column and end_column fields. In other words, you cannot specify just one value, you need to provide both. Could you please try to add "end_column": 1 with version 0.3.0?

ggrossetie commented 3 years ago

For reference, we automatically transform "line": 7 to "start_line": 7, "end_line": 7.

emily-hawkins commented 3 years ago

that fixed it! thank you!

ggrossetie commented 3 years ago

If start_column, end_column or column are defined we could potentially define both start_column and end_column using the same value.

Since we are already doing that for line, I think it would make sense. What do you think?

emily-hawkins commented 3 years ago

If start_column, end_column or column are defined we could potentially define both start_column and end_column using the same value.

Since we are already doing that for line, I think it would make sense. What do you think?

that seems fine to me! we already updated our output to have both start and end but it might be helpful for someone else down the line