Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sendFile error on AttachmentFile with bytes and no name #1724

Closed
1 task done
edeetee opened this issue Sep 2, 2023 · 0 comments · Fixed by #1730
Closed
1 task done

sendFile error on AttachmentFile with bytes and no name #1724

edeetee opened this issue Sep 2, 2023 · 0 comments · Fixed by #1730
Labels
bug Something isn't working

Comments

@edeetee
Copy link
Contributor

edeetee commented Sep 2, 2023

Which packages are you using?

stream_chat_flutter

On what platforms did you experience the issue?

Web

What version are you using?

6.9.0

What happened?

Issue

When sending an AttachmentFIle without a name, I get an unhelpful error message from the server:

StreamChatNetworkError(code: 4, message: UploadFile failed with error: "http: no such file", statusCode: 400, data: ErrorResponse(code: 4, message: UploadFile failed with error: "http: no such file", statusCode: 400, moreInfo: https://getstream.io/chat/docs/api_errors_response))

Workaround

I fixed it by giving it a name.

Solution

I think it would be helpful if the AttachmentFile requires a name in its asserts if it is indeed a requirement of the api. I found it confusing that the server complained about a filename, where it was the name that I needed to change.

It makes sense now that I've solved it but I think it would definitely help onboarding devs.

Steps to reproduce

1. Send an attachment with the given structure

Supporting info to reproduce

Example request

final data = Uint8List(0);
StreamChannel.of(context)
          .channel
          .sendMessage(Message(type: 'voicenote', attachments: [
            Attachment(
              file: AttachmentFile(
                bytes: data,
                size: data.length,
              ),
            )
          ]))

Relevant log output

2023-09-02 14:31:10.246 🚨 🕸️  
js_primitives.dart:30 2023-09-02 14:31:10.247 🚨 🕸️ ╔╣ DioException ║ Status: 400  
js_primitives.dart:30 2023-09-02 14:31:10.247 🚨 🕸️ ║  https://chat.stream-io-api.com/channels/messaging/Test1/file?api_key=3nzhuaandy4g&user_id=tutorial-flutter&connection_id=648d7050-0a0b-36de-0000-00000267c173 
js_primitives.dart:30 2023-09-02 14:31:10.247 🚨 🕸️ ╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝ 
js_primitives.dart:30 2023-09-02 14:31:10.247 🚨 🕸️ ╔ DioExceptionType.badResponse 
js_primitives.dart:30 2023-09-02 14:31:10.247 🚨 🕸️ ║    { 
js_primitives.dart:30 2023-09-02 14:31:10.248 🚨 🕸️ ║         code: 4, 
js_primitives.dart:30 2023-09-02 14:31:10.248 🚨 🕸️ ║         message: "UploadFile failed with error: "http: no such file"", 
js_primitives.dart:30 2023-09-02 14:31:10.248 🚨 🕸️ ║         StatusCode: 400, 
js_primitives.dart:30 2023-09-02 14:31:10.249 🚨 🕸️ ║         duration: "0.00ms", 
js_primitives.dart:30 2023-09-02 14:31:10.249 🚨 🕸️ ║         more_info: "https://getstream.io/chat/docs/api_errors_response", 
js_primitives.dart:30 2023-09-02 14:31:10.249 🚨 🕸️ ║         details: [] 
js_primitives.dart:30 2023-09-02 14:31:10.249 🚨 🕸️ ║    } 
js_primitives.dart:30 2023-09-02 14:31:10.249 🚨 🕸️ ╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝ 
js_primitives.dart:30 2023-09-02 14:31:10.250 🚨 🕸️  
js_primitives.dart:30 2023-09-02 14:31:10.250 🚨 📡 error uploading the attachment 
js_primitives.dart:30 StreamChatNetworkError(code: 4, message: UploadFile failed with error: "http: no such file", statusCode: 400, data: ErrorResponse(code: 4, message: UploadFile failed with error: "http: no such file", statusCode: 400, moreInfo: https://getstream.io/chat/docs/api_errors_response))
js_primitives.dart:30 dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 294:49  throw_
packages/stream_chat/src/core/http/stream_http_client.dart 151:7              post
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 60:31            <fn>
packages/stack_trace/src/stack_zone_specification.dart 135:43                 <fn>
packages/stack_trace/src/stack_zone_specification.dart 204:15                 [_run]
packages/stack_trace/src/stack_zone_specification.dart 135:31                 <fn>
dart-sdk/lib/async/zone.dart 1423:47                                          _rootRunBinary
dart-sdk/lib/async/zone.dart 1315:19                                          runBinary
dart-sdk/lib/async/future_impl.dart 171:22                                    handleError
dart-sdk/lib/async/future_impl.dart 852:46                                    handleError
dart-sdk/lib/async/future_impl.dart 873:13                                    _propagateToListeners
dart-sdk/lib/async/future_impl.dart 649:5                                     [_completeError]
dart-sdk/lib/async/future_impl.dart 60:12                                     [_completeError]
dart-sdk/lib/async/future_impl.dart 26:5                                      completeError
dart-sdk/lib/async/future.dart 620:44                                         onError
packages/stack_trace/src/stack_zone_specification.dart 135:43                 <fn>
packages/stack_trace/src/stack_zone_specification.dart 204:15                 [_run]
packages/stack_trace/src/stack_zone_specification.dart 135:31                 <fn>
dart-sdk/lib/async/zone.dart 1423:47                                          _rootRunBinary
dart-sdk/lib/async/zone.dart 1315:19                                          runBinary
dart-sdk/lib/async/future_impl.dart 171:22                                    handleError
dart-sdk/lib/async/future_impl.dart 852:46                                    handleError
dart-sdk/lib/async/future_impl.dart 873:13                                    _propagateToListeners
dart-sdk/lib/async/future_impl.dart 649:5                                     [_completeError]
dart-sdk/lib/async/future_impl.dart 739:7                                     <fn>
packages/stack_trace/src/stack_zone_specification.dart 204:15                 [_run]
packages/stack_trace/src/stack_zone_specification.dart 114:48                 <fn>
dart-sdk/lib/async/zone.dart 1399:13                                          _rootRun
dart-sdk/lib/async/zone.dart 1301:19                                          run
dart-sdk/lib/async/zone.dart 1209:7                                           runGuarded
dart-sdk/lib/async/zone.dart 1249:23                                          callback
dart-sdk/lib/async/schedule_microtask.dart 40:11                              _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5                               _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 181:15           <fn>

Flutter analyze output

No failures

Flutter doctor output

➜ flutter doctor -v              
[✓] Flutter (Channel stable, 3.13.1, on macOS 13.4.1 22F82
    darwin-arm64, locale en-NZ)
    • Flutter version 3.13.1 on channel stable at
      /Users/edwardtaylor/opt/flutter
    • Upstream repository
      https://github.com/flutter/flutter.git
    • Framework revision e1e47221e8 (10 days ago), 2023-08-22
      21:43:18 -0700
    • Engine revision b20183e040
    • Dart version 3.1.0
    • DevTools version 2.25.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /Users/edwardtaylor/Library/Android/sdk
    • Platform android-33, build-tools 33.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14B47b
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)

[✓] IntelliJ IDEA Community Edition (version 2022.3.3)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.81.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.70.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 13.4.1 22F82 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 116.0.5845.110

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Code of Conduct

  • I agree to follow this project's Code of Conduct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant