bug: dist/index.js is stale — calls deprecated Azure endpoint, breaking prompt/advanced modes entirely

Open Beginner friendly
#2 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
86/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
github-actions, javascript

Research direction

Start with action.yml to confirm dist/index.js is the runtime entry point, then compare src/agent.js with the generated dist/index.js and review build-dist.yml. Run npm ci and npm run build, inspect the resulting dist/ changes, and verify that the generated artifact reflects the current source before committing it.

Written by the indexing model from the issue text.

Description

Bug Report

Summary

dist/index.js — the actual file that runs when the action is invoked (per action.yml: main: dist/index.js) — is severely out of sync with the current src/ code. This makes prompt and advanced modes completely non-functional for every user of this action.


What the dist does (broken)
// dist/index.js — what actually runs
const response = await fetch("https://models.inference.ai.azure.com/chat/completions", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${token}`,
    "Content-Type": "application/json",
    // No Accept header
    // No X-GitHub-Api-Version header
    // No AbortController / timeout
  },
});

if (!response.ok) {
  core.setFailed(...); // crashes the entire action on any API error
}

// No null checks — throws if AI returns unexpected JSON shape
const resultObj = JSON.parse(data.choices[0].message.content);
What the src does (correct)
// src/agent.js — never built into dist
const response = await fetch("https://models.github.ai/inference/chat/completions", {
  headers: {
    "Authorization": `Bearer ${token}`,
    "Content-Type": "application/json",
    "Accept": "application/vnd.github+json",
    "X-GitHub-Api-Version": "2026-03-10",
  },
  signal: controller.signal, // 30s timeout via AbortController
});

if (!response.ok) {
  core.warning(...); // graceful degradation
  return [];
}
// full null-safety, JSON parse error handling, deduplication logic

Comparison Table
dist/index.js (what runs) src/agent.js (never built)
API endpoint models.inference.ai.azure.com (deprecated) models.github.ai/inference
Timeout None — hangs forever 30s AbortController
On API error core.setFailed — kills entire action core.warning + graceful []
JSON parse safety Crashes on bad AI response Try/catch with warning
Accept header Missing application/vnd.github+json
API version header Missing X-GitHub-Api-Version: 2026-03-10
Base issue merging/dedup Missing Full deduplication logic

Impact
  • prompt and advanced modes are 100% broken — the old Azure endpoint either rejects requests or returns responses in a format the old code cannot handle, causing the action to crash via setFailed.
  • preset mode still works because it does not touch the AI endpoint.
  • This affects every repository using this action in prompt or advanced mode.

Root Cause

The build-dist.yml workflow only rebuilds dist/ when a PR is merged to main. The current src/agent.js was updated with a new endpoint, timeout, better error handling, and deduplication logic — but a rebuild was never committed. The stale dist/index.js therefore still targets the old deprecated Azure endpoint.


Fix

Run npm run build and commit the result:

npm ci
npm run build
git add dist/
git commit -m "fix: rebuild dist with correct GitHub Models endpoint and error handling"
git push
Dominant language
JavaScript
Stars
7
Forks
3
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.