Skip to content

fix(request): stop sendRequest early when validation fails#1619

Open
AyushCoder9 wants to merge 1 commit intofoss42:mainfrom
AyushCoder9:fix/abort-invalid-request-send
Open

fix(request): stop sendRequest early when validation fails#1619
AyushCoder9 wants to merge 1 commit intofoss42:mainfrom
AyushCoder9:fix/abort-invalid-request-send

Conversation

@AyushCoder9
Copy link
Copy Markdown
Contributor

PR Description

This PR ensures sendRequest() exits immediately when request validation fails.

Before this change, validation errors were logged in terminal but execution could still continue and start the network flow. Now, after logging the validation error and setting terminal badge, the function returns early. This keeps behavior safe and avoids unnecessary network calls for invalid requests.

Also added a regression test:

  • test/providers/collection_validation_test.dart
    • verifies sendRequest() early-exits on invalid request input
    • verifies validation error is logged in terminal
    • verifies no response status is set from network execution.

Related Issues

  • Closes #

Checklist

  • I have gone through the contributing guide
  • I have updated my branch and synced it with project main branch before making this PR
  • I am using the latest Flutter stable branch (run flutter upgrade and verify)
  • I have run the tests (flutter test) and all tests are passing

Added/updated tests?

We encourage you to add relevant test cases.

  • Yes
  • No, and this is why: please replace this line with details on why tests have not been included

OS on which you have developed and tested the feature?

  • Windows
  • macOS
  • Linux

Return early after validation errors so invalid requests do not trigger network execution, and add a provider test covering the early-exit behavior.

Made-with: Cursor
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