Skip to content

Fix Copy as cURL omitting headers and body on failed requests - #9963

Open
muhammadkamel wants to merge 3 commits into
flutter:masterfrom
muhammadkamel:fix/network-copy-as-curl-body
Open

Fix Copy as cURL omitting headers and body on failed requests#9963
muhammadkamel wants to merge 3 commits into
flutter:masterfrom
muhammadkamel:fix/network-copy-as-curl-body

Conversation

@muhammadkamel

Copy link
Copy Markdown
Contributor

Summary

  • Copy as cURL from the Network profiler dropped request headers and body when the HTTP response never completed (timeouts, connection errors, cancelled POSTs).
  • The generated command was only curl --location --request POST 'url' even though the app had sent JSON and headers.
  • Fetch full profile data before copying, keep request headers/body when no response arrives, and cover this with unit tests.

This is a Network profiler bug found while copying a timed-out POST from DevTools. There is no open issue for the missing body; related history: #3042 (original Copy as cURL), #9828 (copy request like the browser).

Test plan

  • flutter test packages/devtools_app/test/http/curl_command_test.dart
  • flutter test packages/devtools_app/test/screens/network/network_model_test.dart
  • In DevTools Network: Copy as cURL on a completed POST includes --header and --data-raw
  • Copy as cURL on a timed-out / failed POST still includes body/headers when the VM profile recorded them
  • Copy as URL is unchanged

Pre-launch Checklist

General checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read the Flutter Style Guide recently, and have followed its advice.
  • I signed the CLA.
  • I updated/added relevant documentation (doc comments with ///).

Issues checklist

  • I listed at least one issue that this PR fixes in the description above.
  • I listed at least one issue which has the contributions-welcome or good-first-issue label.
  • I did not list at least one issue with the [contributions-welcome] or [good-first-issue] label. I understand this means my PR might take longer to be reviewed.

Tests checklist

  • I added new tests to check the change I am making...
  • OR there is a reason for not adding tests, which I explained in the PR description.

AI-tooling checklist

  • I did not use any AI tooling in creating this PR.
  • OR I did use AI tooling, and...
    • I read the AI contributions guidelines and agree to follow them.
    • I reviewed all AI-generated code before opening this PR.
    • I understand and am able to discuss the code in this PR.
    • I have verifed the accuracy of any AI-generated text included in the PR description.
    • I commit to verifying the accuracy of any AI-generated code or text that I upload in response to review comments.

Feature-change checklist

  • This PR does not change the DevTools UI or behavior and...
    • I added the release-notes-not-required label or left a comment requesting the label be added.
  • OR this PR does change the DevTools UI or behavior and...
    • I added an entry to packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md.
    • I included before/after screenshots and/or a GIF demo of the new UI to my PR description.
    • I ran the DevTools app locally to manually verify my changes.

Timed-out and cancelled POSTs never complete a response, so the Network
profiler dropped request data from the generated curl command.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances the "Copy as cURL" feature in the network profiler to include request headers and bodies for failed, timed-out, or cancelled requests, and adds corresponding tests. The review feedback identifies two critical areas where asynchronous calls to getFullRequestData() using unawaited could lead to unhandled exceptions, recommending the use of try-catch blocks or .catchError to handle potential errors gracefully.

Comment thread packages/devtools_app/lib/src/screens/network/network_screen.dart
Comment thread packages/devtools_app/lib/src/shared/http/http_request_data.dart
Merge upstream master to resolve merge conflicts and pick up pinned
GitHub Actions (fixes zizmor-output). Handle getFullRequestData failures
gracefully when copying as cURL or prefetching request data.
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