fix(dispatch): nextJobRef lisait r.data (objet) au lieu de r.data.data → collisions ticket_id → « Failed to create dispatch job »
Bug : nextJobRef() faisait 'for..of r.data' alors que la liste ERPNext est sous r.data.data (comme partout ailleurs dans dispatch.js). r.data étant un objet → 'object is not iterable' → catch → repli ymd+'-001' à CHAQUE appel. Donc le 1er job du jour passe, les suivants COLLISIONNENT sur le même ticket_id (autoname) → POST rejeté → createDispatchJob lève 'Failed to create dispatch job'. Touchait TOUTE création via createDispatchJob (agent NL create_job, /dispatch/ create-job, chaînes d'installation), pas seulement l'assistant. Fix : itérer r.data.data. Vérifié : 2 créations consécutives → refs 20260719-001 puis -002 (distincts, incrémentés), plus d'erreur 'not iterable'. Déployé, hub sain. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
c4c4cc6575
commit
6022cdf5fb
|
|
@ -426,7 +426,7 @@ async function nextJobRef () {
|
|||
const fields = encodeURIComponent(JSON.stringify(['name']))
|
||||
const r = await erpFetch(`/api/resource/Dispatch Job?filters=${filters}&fields=${fields}&limit_page_length=0`)
|
||||
const re = new RegExp('^' + ymd + '-(\\d{3})$')
|
||||
for (const j of ((r && r.data) || [])) { const m = re.exec(String(j.name || '')); if (m) { const n = parseInt(m[1], 10); if (n > max) max = n } }
|
||||
for (const j of ((r && r.data && r.data.data) || [])) { const m = re.exec(String(j.name || '')); if (m) { const n = parseInt(m[1], 10); if (n > max) max = n } }
|
||||
} catch (e) { log('nextJobRef: ' + e.message) }
|
||||
return ymd + '-' + String(max + 1).padStart(3, '0')
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user