Skip to content

fix: [NACT-2932] retry GitLab MR creation and stop blocking on traceback rendering - #650

Open
feiyunzhou wants to merge 1 commit into
Roche:mainfrom
feiyunzhou:nact-2932-fix-foxops-mr-creation-race-and-timeout-handling
Open

feiyunzhou wants to merge 1 commit into
Roche:mainfrom
feiyunzhou:nact-2932-fix-foxops-mr-creation-race-and-timeout-handling

Conversation

@feiyunzhou

@feiyunzhou feiyunzhou commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

WHY?

Nightly nactl update runs fail intermittently. foxops pushes the branch and
asks GitLab to open an MR in the same breath; GitLab answers from a branch cache
that can lag the push and rejects it with Source branch "<x>" does not exist.
foxops did not retry. Logging the resulting error then took ~52s, which pushed
the reply past the 60s reverse-proxy timeout, so the caller saw a misleading 504
instead of the real GitLab error.

WHAT?

  • Retry the merge request POST for up to 10s while GitLab still reports the
    pushed source branch as missing. Safe to retry: GitLab only sends this message
    when it created nothing.
  • Raise MergeRequestCreationFailedError carrying GitLab's own message, instead
    of httpx's Client error '400 Bad Request' for url ....
  • Render plain tracebacks. structlog's ConsoleRenderer silently switches to
    rich's formatter when rich is installed, and that formatter reprs every
    frame's local variables.

ADDITIONAL NOTES

The traceback was rendered twice per failed request — once in catch_all, once
more after Starlette re-raises and uvicorn logs it. Rendering is synchronous on
the event loop, so it stalled every other in-flight request too, and the first
render happens before the error response is sent.

Not touched: the mergeability-check loop in merge_request() can still spend up
to 25s of the same 60s budget. Separate concern.

@feiyunzhou
feiyunzhou requested a review from defreng as a code owner October 6, 2026 09:00
@feiyunzhou feiyunzhou closed this Oct 6, 2026
@feiyunzhou feiyunzhou reopened this Oct 6, 2026
@tech1ndex
tech1ndex self-requested a review October 6, 2026 11:22
@feiyunzhou
feiyunzhou force-pushed the nact-2932-fix-foxops-mr-creation-race-and-timeout-handling branch from 8d59890 to 39ee978 Compare October 8, 2026 12:46
…ack rendering

foxops asks GitLab to open a merge request immediately after pushing the
branch. GitLab answers from a branch cache that can lag the push, rejects the
request with `Source branch "<x>" does not exist`, and foxops did not retry.

The resulting traceback then took ~52s to log, because structlog's
ConsoleRenderer falls back to rich's traceback formatter whenever rich is
installed, and that formatter renders every frame's local variables. It ran
twice per failed request: once in catch_all, once more after Starlette
re-raises and uvicorn logs it. Rendering is synchronous on the event loop and
happens before the error response is sent, so replies missed the 60s
reverse-proxy timeout and callers saw a misleading 504.

- retry the merge request POST for up to 10s while GitLab reports the pushed
  source branch as missing
- raise MergeRequestCreationFailedError with GitLab's own message instead of
  httpx's "Client error '400 Bad Request' for url ..."
- render plain tracebacks, without frame locals
@feiyunzhou
feiyunzhou force-pushed the nact-2932-fix-foxops-mr-creation-race-and-timeout-handling branch from 39ee978 to f6c581e Compare October 8, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant