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

Getting a GitHubApiError when running this action #36

Open
emily-hawkins opened this issue Jul 14, 2021 · 6 comments
Open

Getting a GitHubApiError when running this action #36

emily-hawkins opened this issue Jul 14, 2021 · 6 comments
Labels
🍩 enhancement New feature or request

Comments

@emily-hawkins
Copy link

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
Copy link
Author

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

@ggrossetie
Copy link
Member

ggrossetie commented Jul 14, 2021

It seems that some fields are invalid.

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

  • file
  • line
  • message
  • title
  • annotation_level (if it contains a valid value)

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
Copy link
Member

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

@emily-hawkins
Copy link
Author

that fixed it! thank you!

@ggrossetie
Copy link
Member

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?

@ggrossetie ggrossetie added the 🍩 enhancement New feature or request label Jul 16, 2021
@emily-hawkins
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍩 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants