AOSSIE-Org / AOSSIE-Org/AutoInitialIssues

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

Open
#2 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7
Forks
3
PR merge metrics
No merged PRs in 30d

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)

```js
// 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)

```js
// 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:

```bash
npm ci
npm run build
git add dist/
git commit -m "fix: rebuild dist with correct GitHub Models endpoint and error handling"
git push
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.