Fix: AddJob was completely wrong. The job_repo_id is a bijection; updated all code

This commit is contained in:
Michael Hohn
2025-08-04 13:30:43 -07:00
committed by =Michael Hohn
parent 1377d4cec9
commit 807d5f3d45
4 changed files with 115 additions and 108 deletions

View File

@@ -179,20 +179,7 @@ func (c *CommanderSingle) submitStatusResponse(w http.ResponseWriter, js common.
// The jobRepoId from the range should now match the stored job_repo_id
// due to the ORDER BY job_repo_id in GetJobList()
for jobRepoId, job := range jobs {
// Validate that the slice index matches the expected repo ID
// This helps catch ordering issues between different state implementations
if expectedJobSpec, err := c.v.State.GetJobSpecByRepoId(js.SessionID, jobRepoId); err != nil {
slog.Warn("Job repo ID validation failed",
"sessionId", js.SessionID,
"jobRepoId", jobRepoId,
"error", err)
} else if expectedJobSpec.Owner != job.Spec.Owner || expectedJobSpec.Repo != job.Spec.Repo {
slog.Error("Job repo ID mismatch detected",
"sessionId", js.SessionID,
"jobRepoId", jobRepoId,
"expected", expectedJobSpec.NameWithOwner,
"actual", job.Spec.NameWithOwner)
}
// Get the job status
status, err := c.v.State.GetStatus(job.Spec)
if err != nil {