mujx / hakatime

Wakatime server implementation & analytics dashboard
https://hakatime.mtx-dev.xyz
The Unlicense
610 stars 45 forks source link

Github - Time Spent Per Commit not working (Not Found) #87

Open jontstaz opened 9 months ago

jontstaz commented 9 months ago

Hi,

Nice project. However I'm facing a specific issue. I have many projects connected to Github repos that are both private and public. When I try to use the Time Spent Per Commit feature, it throws a red alert error at the top right saying "Failed to fetch the commit log". Then when I look at the Docker logs I see the following:

hakatime  |   host                 = "api.github.com"
hakatime  |   port                 = 443
hakatime  |   secure               = True
hakatime  |   requestHeaders       = [("Authorization","<REDACTED>"),("User-Agent","Hakatime Server"),("Accept","application/json")]
hakatime  |   path                 = "/repos/<my_gh_username>/<my_repo>/commits"
hakatime  |   queryString          = "?per_page=81"
hakatime  |   method               = "GET"
hakatime  |   proxy                = Nothing
hakatime  |   rawBody              = False
hakatime  |   redirectCount        = 10
hakatime  |   responseTimeout      = ResponseTimeoutDefault
hakatime  |   requestVersion       = HTTP/1.1
hakatime  |   proxySecureMode      = ProxySecureWithConnect
hakatime  | }
hakatime  |  (StatusCodeException (Response {responseStatus = Status {statusCode = 404, statusMessage = "Not Found"}, responseVersion = HTTP/1.1, responseHeaders = [("Server","GitHub.com"),("Date","Wed, 13 Sep 2023 09:54:17 GMT"),("Content-Type","application/json; charset=utf-8"),("Transfer-Encoding","chunked"),("X-GitHub-Media-Type","github.v3"),("x-github-api-version-selected","2022-11-28"),("X-RateLimit-Limit","60"),("X-RateLimit-Remaining","40"),("X-RateLimit-Reset","1694599592"),("X-RateLimit-Used","20"),("X-RateLimit-Resource","core"),("Access-Control-Expose-Headers","ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset"),("Access-Control-Allow-Origin","*"),("Strict-Transport-Security","max-age=31536000; includeSubdomains; preload"),("X-Frame-Options","deny"),("X-Content-Type-Options","nosniff"),("X-XSS-Protection","0"),("Referrer-Policy","origin-when-cross-origin, strict-origin-when-cross-origin"),("Content-Security-Policy","default-src 'none'"),("Vary","Accept-Encoding, Accept, X-Requested-With"),("Content-Encoding","gzip"),("X-GitHub-Request-Id","D922:4CCA:F1B5C5:1008E93:650186C9")], responseBody = (), responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose, responseOriginalRequest = Request {

Is this a known issue? I've got the correct permissions on my Personal Access Token. I've even tried using a token with all permissions enabled just to test but same result. And interestingly, when I look at the list of the tokens on Github, they each say Never used.

Here's my Docker-Compose config for context:

version: "3"
services:
  server:
    container_name: hakatime
    image: mujx/hakatime:v1.7.3
    environment:
      # DB settings.
      HAKA_DB_HOST: haka_db
      HAKA_DB_PORT: 5432
      HAKA_DB_NAME: hakatime
      HAKA_DB_PASS: <my_pg_pw>
      HAKA_DB_USER: <my_pg_user>
      # Server settings.
      # Fill out this field if the api is behind another path (e.g behind a reverse proxy).
      # This will adjust the Set-Cookie path for all the /auth related API calls.
      HAKA_API_PREFIX: ""
      # Update this with the external endpoint that you use to access hakatime.
      HAKA_BADGE_URL: "https://<my_hakatime_instance_url>"
      HAKA_PORT: 8080
      HAKA_SHIELDS_IO_URL: "https://img.shields.io"
      HAKA_ENABLE_REGISTRATION: "true" # Toggle after you've created your account.
      # Number of hours after which inactive browser sessions will expire (login required).
      HAKA_SESSION_EXPIRY: "24"
      HAKA_LOG_LEVEL: "info" # Control the verbosity of the logger.
      HAKA_ENV: "dev" # Use a json logger for production, otherwise key=value pairs.
      HAKA_HTTP_LOG: "true" # If you want to log http requests.
      GITHUB_TOKEN: "<ghp_my_token>" # If you want to retrieve time spent per commit. No extra scope is required.
      # Add the following variables if you want to forward any received heartbeats to another
      # Wakatime compatible server.
      HAKA_REMOTE_WRITE_URL: "https://wakatime.com/api/v1/users/current/heartbeats.bulk"
      HAKA_REMOTE_WRITE_TOKEN: "<my_wakatime.com_api_key>"
    ports:
      - "3117:8080"
  haka_db:
    container_name: haka_db
    image: postgres:12-alpine
    environment:
      POSTGRES_DB: hakatime
      POSTGRES_PASSWORD: <pg_password>
      POSTGRES_USER: <pg_user>
    volumes:
      - deploy_db_data:/var/lib/postgresql/data

volumes:
  deploy_db_data: {}

Thanks in advance

lokize commented 2 weeks ago

same problem here...