extract_issue_ref_from_message misparses /issues/ URLs — drops instance #177

Closed
opened 2026-04-06 04:39:53 +02:00 by shoko · 0 comments
Owner

Summary

extract_issue_ref_from_message() in kugetsu-session.sh incorrectly parses full URLs containing /issues/. The instance prefix is dropped and /issues/ becomes the repo field.

Affected Code

File: kugetsu-session.sh, extract_issue_ref_from_message() (lines 159-167)

The sed pipeline drops the instance when cutting from field 2:

local path=$(echo "$url" | sed 's|https\?://||' | cut -d'/' -f2-)
local instance=$(echo "$path" | cut -d'/' -f1)  # WRONG
local owner=$(echo "$path" | cut -d'/' -f2)    # WRONG
local repo=$(echo "$path" | cut -d'/' -f3)       # WRONG

For URL https://git.fbrns.co/shoko/kugetsu/issues/158:

After sed: git.fbrns.co/shoko/kugetsu/issues/158
After cut -f2-: shoko/kugetsu/issues/158 (4 fields — instance dropped)

Then:

  • instance = shoko (should be git.fbrns.co)
  • owner = kugetsu (should be shoko)
  • repo = issues (should be kugetsu)
  • num = 158 (correct)

Result: shoko/kugetsu/issues#158 — invalid format, 4 segments before #.

Expected

Input: https://git.fbrns.co/shoko/kugetsu/issues/158
Output: git.fbrns.co/shoko/kugetsu#158

Fix

Count from the end since URL structure after instance is always owner/repo/issues/NUMBER:

local path="${url#http://}"
path="${path#https://}"
local instance=$(echo "$path" | cut -d'/' -f1)
local owner=$(echo "$path" | cut -d'/' -f2)
local repo=$(echo "$path" | cut -d'/' -f3)
local num=$(echo "$path" | grep -oE '[0-9]+$')

Reproduction

bash -c '
source kugetsu-session.sh
msg="https://git.fbrns.co/shoko/kugetsu/issues/158 — test"
result=$(extract_issue_ref_from_message "$msg")
echo "$result"
'
# Output: shoko/kugetsu/issues#158
# Expected: git.fbrns.co/shoko/kugetsu#158

Impact

Every delegated task fails immediately. Malformed issue_ref reaches cmd_start where validate_issue_ref rejects it (expects 3 segments, gets 4) and task is marked error. This is the only remaining blocker for queue-based delegation working.

## Summary `extract_issue_ref_from_message()` in `kugetsu-session.sh` incorrectly parses full URLs containing `/issues/`. The instance prefix is dropped and `/issues/` becomes the repo field. ## Affected Code **File:** `kugetsu-session.sh`, `extract_issue_ref_from_message()` (lines 159-167) The sed pipeline drops the instance when cutting from field 2: ```bash local path=$(echo "$url" | sed 's|https\?://||' | cut -d'/' -f2-) local instance=$(echo "$path" | cut -d'/' -f1) # WRONG local owner=$(echo "$path" | cut -d'/' -f2) # WRONG local repo=$(echo "$path" | cut -d'/' -f3) # WRONG ``` For URL `https://git.fbrns.co/shoko/kugetsu/issues/158`: After sed: `git.fbrns.co/shoko/kugetsu/issues/158` After cut -f2-: `shoko/kugetsu/issues/158` (4 fields — instance dropped) Then: - instance = `shoko` (should be `git.fbrns.co`) - owner = `kugetsu` (should be `shoko`) - repo = `issues` (should be `kugetsu`) - num = `158` (correct) Result: `shoko/kugetsu/issues#158` — invalid format, 4 segments before #. ## Expected Input: `https://git.fbrns.co/shoko/kugetsu/issues/158` Output: `git.fbrns.co/shoko/kugetsu#158` ## Fix Count from the end since URL structure after instance is always owner/repo/issues/NUMBER: ```bash local path="${url#http://}" path="${path#https://}" local instance=$(echo "$path" | cut -d'/' -f1) local owner=$(echo "$path" | cut -d'/' -f2) local repo=$(echo "$path" | cut -d'/' -f3) local num=$(echo "$path" | grep -oE '[0-9]+$') ``` ## Reproduction ``` bash -c ' source kugetsu-session.sh msg="https://git.fbrns.co/shoko/kugetsu/issues/158 — test" result=$(extract_issue_ref_from_message "$msg") echo "$result" ' # Output: shoko/kugetsu/issues#158 # Expected: git.fbrns.co/shoko/kugetsu#158 ``` ## Impact Every delegated task fails immediately. Malformed issue_ref reaches cmd_start where validate_issue_ref rejects it (expects 3 segments, gets 4) and task is marked error. This is the only remaining blocker for queue-based delegation working.
shoko closed this issue 2026-04-06 07:16:28 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shoko/kugetsu#177