question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Most probot implementations don't set started_at resulting in bad output from GitHub

See original GitHub issue

Bug Report

probot derivatives generally fail to set started_at. This is fine for checks.runs calls when status!=completed, because afaict (and as confirmed by @tcbyrd), the GitHub endpoint fills in started_at with Date.now() for when the endpoint is called.

@tcbyrd writes:

looks like in the post route we don’t require it because we do this: data["started_at"] ||= Time.now.utc

This is less good for status=completed, because per checks.runs, completed_at is a mandatory field in that case, and unless the app is time warping, its value (also calculated from Date.now()) will be before the API endpoint is called, which results in things like:

  • DCO Successful in -1m — DCO (in the Conversation view) — because the completed_at happens just before the started_at is calculated, and the basic subtraction results in a negative number (-1).
  • ran ... days ago in less than 5 seconds (in the Checks view) — because the completed_at happens just before the started_at is calculated, and the basic subtraction results in a negative number (-1), and while that should result in -1 as with the other view, there seems to be some logic that says if delta < 5s -> show less than 5 seconds.

Expected behavior/code Templates should default to filling in the started_at field, and ideally there should be a warning if it isn’t filled in so that app authors discover that they should fill it in.

Environment

  • Probot version(s): master
  • Node/npm version: unknown
  • OS: all

Possible Solution Adjust template, add warnings.

Additional context/Screenshots DCO (Conversation view): image

Prosebot (Checks view): image

– This is mostly a place to hang fixes for individual apps, and also, perhaps, for @tcbyrd to update us on when the API endpoint is improved.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
tcbyrdcommented, Mar 8, 2019

The negative numbers should be resolved now on the github side. We still recommend providing it when necessary, but now in these scenarios where the check completes that quickly, we just don’t show any time-related data. Can we close since it started with “bad output from GitHub” and start a new tracking issue if we want to improve things with hooks beyond that?

1reaction
gr2mcommented, Jan 6, 2019

What I’d suggest to do is set a before request hook on the Octokit instance passed to the event handlers. It does two things

  1. Keeps track of the time the event was received
  2. It checks if a request creates a check run. If it is, default the started_at timestamp to the time from 1. if it’s not set by the user.

This is an interesting topic, thanks for bringing that up. I’ll discuss it with the other Octokit maintainers, too. It might be good example for sth the Octokit libraries could take care of in a standardized way. I’ll bring it up with the docs team, too, maybe we should add a note to https://developer.github.com/v3/guides/best-practices-for-integrators

<div>GitHub Developer</div><div>Best practices for integrators</div><div>Get started with one of our guides, or jump straight into the API documentation.</div>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Probot app throwing 'ERROR (server): Bad Request' #1713
Bug Report Current Behavior App not working, giving error whenever it receives a payload. /** * This is the main entrypoint to your...
Read more >
probot/stats endpoint is not scalable · Issue #380 - GitHub
At app startup, the /probot/stats endpoint fetches all the repositories for all the installations that the app is installed on.
Read more >
Some apps need persistence--we should provide an ... - GitHub
tl;dr While most apps can get all the data they need from the GitHub API, some need to persist data. We should provide...
Read more >
Probot's setup mode is easily overlooked and leaves ... - GitHub
I am trying to add a simple express route for a health check on my probot app. I was getting a 404 on...
Read more >
When searching for issues, I'm receiving issues from orgs ...
I created a GitHub App under my personal developer settings. I've only granted read permissions to metadata, issues, and the single config file....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found