refactor(upload): resolve the upload id before the quarantine step - #1197
refactor(upload): resolve the upload id before the quarantine step#1197max-trunk wants to merge 1 commit into
Conversation
`createBundleUpload` ran inside `upload_bundle`, after the quarantine step had already logged each failure — so the per-failure `Learn more` lines fell back to the short link while the report table used the GUID, two URL shapes for the same test in one run. Hoisting the call above `gather_exit_code_and_quarantined_tests_context` gives both lanes the same ids, and `upload_bundle` now takes the resolved `Result` instead of making the call itself. Scope, measured rather than assumed: those lines are `tracing::info!`, and the console layer is only installed above info level (`cli/src/main.rs`), so they reach stdout only under `--verbose`. A default run shows the report table on stderr and was already fully on the GUID form after the previous commit. The new test therefore drives `--verbose`; it fails without this change. Two things this deliberately does not disturb: - The RPC error is still held until the upload below, where it has always surfaced. Failing at the new call site would skip quarantine resolution and change the exit code. - The presigned S3 PUT URL has a 3600s TTL, so moving the quarantine fetch and internal-file generation ahead of the PUT has an hour of headroom. `gather_upload_id_context` mutates `bundle_upload_id`, `bundle_upload_id_v2` and `base_props.test_collection`; nothing between the old and new call sites reads them, and `upload_bundle` no longer needs `&mut BundleMeta` at all. The two request-order assertions that now see createBundleUpload first are updated in place — that reordering is the change, not an incidental break. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
| // Ahead of the quarantine step so the failures it logs can be addressed by GUID. Its error | ||
| // is deliberately held until the upload below, where it has always surfaced -- failing here | ||
| // would skip quarantine resolution and change the exit code. | ||
| let upload_id_context = gather_upload_id_context( |
There was a problem hiding this comment.
So this is calling CreateBundleUpload before GetQuarantineConfig? I really don't think we should be doing that. That messes with all the counts we have at upload time for failed tests/quarantined tests/etc
There was a problem hiding this comment.
I'm still reviewing these two PRs, was going to scrutinize this one in particular to see if it was actually necessary
|
Closing this — the reordering costs more than the inconsistency it fixes. Why not land itThe problem is smaller than I first described. The per-failure And moving the call perturbs two measurements. Neither is a correctness bug. Both are the kind of thing that shows up as an unexplained step in a graph weeks later, which is a bad trade for a The better shape, if this ever mattersReturn Groundwork is mostly there: One thing to fix at the same time: The likely trigger for revisiting: promoting the The branch 🤖 Generated with Claude Code |
What this changes
createBundleUploadran insideupload_bundle, after the quarantine step had already logged each failure. So #1196 left one run printing two URL shapes for the same test: the report table on the GUID, the per-failureLearn morelines still on the short link.This hoists the call above
gather_exit_code_and_quarantined_tests_contextand threads the resolved ids intolog_failure, so both lanes agree.upload_bundletakes the resolvedResultinstead of making the call itself.Read this before deciding it is worth landing
The user-visible effect is confined to
--verbose. ThoseLearn morelines aretracing::info!, andcli/src/main.rsonly installs the console layer when verbosity is above info — so in a default run they are not printed at all. A default run shows the stderr report table, which #1196 already put fully on the GUID form.I originally justified this as fixing "two URL shapes in one run". That is real, but only under
-v. Measured, not assumed — the new test drives--verbosebecause that is the only way the behaviour is observable, and it fails without this change.So: reasonable to land for consistency and because it makes
upload_bundlehonest about not mutatingmeta, and reasonable to drop. Not much rides on it either way.Why the reordering is safe
METRICS_BUNDLE_UPLOADS_URL_TTL_SECin trunk1'sbundle_util.ts), so moving the quarantine fetch and internal-file generation ahead of the PUT has an hour of headroom. This was the objection I expected to find and did not.gather_upload_id_contextmutatesbundle_upload_id,bundle_upload_id_v2andbase_props.test_collection; nothing between the old and new call sites reads them, andupload_bundleno longer needs&mut BundleMetaat all.Implementation notes
upload_bundle,test_variant_propagation) now seecreateBundleUploadbeforegetQuarantineConfig. Updated in place — that reordering is the change, not an incidental break.gather_exit_code_and_quarantined_tests_contextandgather_quarantine_context, so both tripclippy::too_many_arguments. Left unsuppressed to match the two existing instances in the same file (9 and 8 params); happy to convert to a params struct if you would rather.Testing
trunk-analytics-cli --test upload: 59 passed, including the new--verbosecaseapi: 25,--test test: 13,--test validate: 9🤖 Generated with Claude Code