[2026 errata] Sprint 2 polling scripts report success and exit 0 when GitHub issue creation or update fails

Aperta
#162 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@drk-ram ci sta già lavorando.

Dal 3/11/2026.

  • #163 di @drk-ram — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
tooling

Direzione di ricerca

Start in 2026/working/polling/scripts/: create_issues.post_issue() and main(), then sync_sprint2.sync_github_issues() and main(). Each returns or appends success even when the API call fails, so exit code and summary are wrong. The payload's stub reproduction shows the expected exit code 2 and the failure list. Linked PR #163 already targets this, so check it before starting.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Affected section

Other (Sprint 2 polling tooling under 2026/working/polling/scripts/)

Where does the issue appear?

GitHub source

What is incorrect?

create_issues.py and sync_sprint2.py report success, and exit with status 0, when every GitHub API call they make fails. Both scripts document a failure exit code in their module docstrings:

EXIT CODES
  0  success
  1  configuration error (missing token, missing args, missing file)
  2  GitHub API error (after creating any issues, prints which ones succeeded)

create_issues.py's docstring promises exit code 2 plus a list of the issues that did succeed; sync_sprint2.py promises 2 GitHub API error during reconciliation or firing. Neither is implemented for issue creation or issue updates:

  1. create_issues.post_issue() returns None on a non-201 response (the same value it returns for a dry run). create_issues.main() ignores the return value, never counts failures, and ends with return 0.
  2. sync_sprint2.sync_github_issues() calls create_issues.post_issue(...) and discards the result, then unconditionally runs summary["created"].append(entry["id"]). In the update paths (force_patch and the changed-entry loop), patch_issue() returns False on failure, but summary["updated"].append(...) is also executed unconditionally.
  3. sync_sprint2.main() finishes with return 0 after printing Created new issues: N, Updated existing issues: N, and the "NEXT STEPS: git add ... issues.json" block. It has already written the new issues.json registry before any issue was fired (Phase 4 runs before Phase 5), so a failed run leaves a registry that claims entries are synchronised while the GitHub issues do not exist.

Only the label upsert (ensure_labels) calls sys.exit(2) on an API failure.

Proposed correction
  • Have post_issue() distinguish "dry run" from "failed" (for example, raise a dedicated exception or return a sentinel), count failures in create_issues.main(), print the entries that succeeded and the ones that failed, and return 2 if any failed.
  • In sync_sprint2.sync_github_issues(), append to summary["created"] / summary["updated"] only when the call succeeded, track a failed list, and have main() return 2 when it is non-empty. Print the failures in the summary and suppress the "NEXT STEPS" block when anything failed.
  • Consider writing issues.json only after the GitHub mutations succeed, or print an explicit warning that the registry was updated while firing failed.
Supporting evidence

Reproduced on origin/main @ 9253e38, Python 3.11, no network access. GitHub's API is replaced with a stub that answers 401 Bad credentials to every request.

create_issues.py (run from 2026/working/polling/scripts/):

python -c "
import os,sys
os.environ['GH_TOKEN']='x'
sys.argv=['create_issues.py','--form-url','https://example.test/form','--skip-labels','--only-ids','LLM01,TA-CFAS']
import create_issues as c
calls=[]
def fake(method,path,token,body=None):
    calls.append((method,path)); return 401,{'message':'Bad credentials'}
c._request=fake
c.time.sleep=lambda s:None
rc=c.main()
print('requests:',calls)
print('exit code:',rc)
"

Output (trimmed to the relevant lines):

[track-b] creating issues
  ! failed to create '[Track B] Feedback: LLM01 — Prompt Injection': status 401 body {'message': 'Bad credentials'}
[track-a] creating issues
  ! failed to create '[Track A] Feedback: Compositional Fine-Tuning Alignment Subversion': status 401 body {'message': 'Bad credentials'}
done.
requests: [('POST', '/repos/GenAI-Security-Project/GenAI-LLM-Top10/issues'), ('POST', '/repos/GenAI-Security-Project/GenAI-LLM-Top10/issues')]
exit code: 0

Both creations failed and the script still ends with done. and exit code 0 instead of 2.

sync_sprint2.py (same directory):

python -c "
import time
time.sleep=lambda s:None
import create_issues as ci, sync_sprint2 as ss
ci._request=lambda *a,**k:(401,{'message':'Bad credentials'})
ss._request=lambda *a,**k:(401,{'message':'Bad credentials'},{})
cfg={'labels':[],'track_a':[],'track_b':[{'id':'LLM01','title':'Prompt Injection','file':'LLM01_PromptInjection.md'}]}
s=ss.sync_github_issues(cfg,{},'https://example.test/form','x',False,[])
print('created:',s['created'])
existing=[{'number':36,'title':'t','labels':[{'name':'LLM01'}]}]
s=ss.sync_github_issues(cfg,{},'https://example.test/form','x',False,existing,force_rebuild=True)
print('updated:',s['updated'])
"

Output:

  ! failed to create '[Track B] Feedback: LLM01 — Prompt Injection': status 401 body {'message': 'Bad credentials'}
created: ['LLM01']
[issues] --force-rebuild: re-rendering covered issues with current templates...
updated: ['LLM01']
    ! patch #36 failed: status 401 body {'message': 'Bad credentials'}

The summary lists LLM01 as created and as updated even though the create and the patch both failed.

Why it matters: these scripts are run by hand to fire the 20 Sprint 2 feedback issues and to reconcile them with the registry that the Apps Script form reads. A token with insufficient scope, an expired token, or a secondary rate limit produces a run that looks successful in the summary and in any wrapper that checks the exit status, while the corresponding issues were never created or updated. The only signal is an interleaved ! line in the log.

Acknowledgments
  • I checked the published release and the canonical GitHub source for an existing correction.
  • I agree to follow the OWASP Code of Conduct.
Lingua principale
JavaScript
Stelle
177
Fork
57
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di GenAI-Security-Project/GenAI-LLM-Top10

Tutte le issue di GenAI-Security-Project/GenAI-LLM-Top10

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.