Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Export Gist button returns 500 error on production (missing or invalid GITHUB_TOKEN) #803

@BoQsc

Description

@BoQsc
Image

Problem

The "Export Gist" button on https://run.dlang.io/ fails with a 500 Internal Server Error when clicked.

Steps to Reproduce

  1. Go to https://run.dlang.io/
  2. Write any D code in the editor
  3. Click the "Export Gist" button

Console Error

POST https://run.dlang.io/api/v1/gist 500 (Internal Server Error)
angular.js:12722 TypeError: Cannot read properties of undefined (reading 'htmlUrl')
    at tour-controller.js:383:21
    at angular.js:14991:28
    at r.$eval (angular.js:16251:16)
    at r.$digest (angular.js:16069:15)
    at r.$apply (angular.js:16359:13)
    at g (angular.js:10791:36)
    at R (angular.js:10989:7)
    at v.onload (angular.js:10930:9)

Root Cause

After reviewing the code, the issue appears to be caused by a missing or invalid GITHUB_TOKEN environment variable on the production server.

Code Flow:

  1. Backend (source/rest/apiv1.d:146-160) attempts to create a GitHub Gist
  2. The authorization header uses githubToken which comes from environment variable
  3. If empty/invalid, GitHub API returns 401 Unauthorized
  4. Backend catches this and returns 500 error: "GitHub API not available"
  5. Frontend (public/static/js/tour-controller.js:381-384) receives undefined data and crashes trying to access data.htmlUrl

Proposed Fix

Set the GITHUB_TOKEN environment variable on the production server as documented in README.md (lines 144-148):

GITHUB_TOKEN

default: (empty)

Required for exporting Gists to GitHub.
Follow these instructions to generate a CLI GitHub token.

Additional Improvements (Optional)

  1. Improve frontend error handling to gracefully handle API failures instead of crashing
  2. Add startup validation to warn when GITHUB_TOKEN is not configured
  3. Show user-friendly error messages when the feature is unavailable

Status of "Shorten" Button

Unknown - needs testing to confirm if it's also affected by similar issues with the is.gd service.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions