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

Print diagnostic message if snapshot creation is not SUCCESS or ACCEPTED #56

Merged
merged 3 commits into from
Jan 12, 2024
Merged

Conversation

mrysav
Copy link
Contributor

@mrysav mrysav commented Jan 4, 2024

I have an Action that uses this library that is failing with an error message like this:

Error: Cannot read properties of null (reading 'toString')
Error: TypeError: Cannot read properties of null (reading 'toString')
    at /home/admin/actions-runner/_work/myrepo/myrepo/purl-submission-action/webpack:/purls-submission-action/node_modules/@github/dependency-submission-toolkit/dist/index.js:506:1
    at Generator.next (<anonymous>)
    at fulfilled (/home/admin/actions-runner/_work/myrepo/myrepo/purl-submission-action/webpack:/purls-submission-action/node_modules/@github/dependency-submission-toolkit/dist/index.js:395:1)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

It seems that this section of code always assumes that there will be a createdAt value that is not null:

core.notice('Snapshot successfully created at ' + response.data.created_at.toString())

However, when I make a cURL request locally, I am getting a response with a null createdAt:

$ curl -u 'user:token' -H 'Content-Type: application/json' 'https://api.my-ghes-instance.com/repos/myuser/myrepo/dependency-graph/snapshots' -d @snap.json

{
  "id": 0,
  "created_at": null,
  "result": "REMOVED",
  "message": "The snapshot was valid, but not accepted. It did not apply to the default branch or was too historical to be considered applicable to the repository and was removed."
}

I figured out the reason for this response, but it would be better if this message was printed in the Action run. Additionally, the REMOVED result is not a documented return value, so that might be something we want to look into.

@mrysav mrysav marked this pull request as ready for review January 4, 2024 18:04
@mrysav mrysav requested a review from a team as a code owner January 4, 2024 18:04
elireisman
elireisman previously approved these changes Jan 4, 2024
@mrysav mrysav merged commit 7a59513 into github:main Jan 12, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants