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

Encountering Unusual Error While Using Bot API's sendPhoto Method with Bot Token #151

Closed
OttomanDeveloper opened this issue Aug 16, 2023 · 14 comments · Fixed by #152
Closed
Labels
bug Something isn't working invalid This doesn't seem right

Comments

@OttomanDeveloper
Copy link

OttomanDeveloper commented Aug 16, 2023

It was working perfectly fine before but today whenever I try to send the photo. I'm getting this issue.
File Path: package:televerse/src/utils/http.dart

response = await _httpClient.multipartPost(
_buildUri("sendPhoto"),
files,
params,
);

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type '_Map<String, dynamic>' is not a subtype of type 'String'
[Offensive text hidden - some testing weirdos I forgot to remove - @HeySreelal]
I/flutter ( 6196): DioException [bad response]: The request returned an invalid status code of 403.
I/flutter ( 6196): #0      DioMixin.fetch.<anonymous closure>
dio_mixin.dart:507
I/flutter ( 6196): #1      _RootZone.runUnary (dart:async/zone.dart:1661:54)
I/flutter ( 6196): #2      _FutureListener.handleError (dart:async/future_impl.dart:165:22)
I/flutter ( 6196): #3      Future._propagateToListeners.handleError (dart:async/future_impl.dart:796:47)
I/flutter ( 6196): #4      Future._propagateToListeners (dart:async/future_impl.dart:817:13)

E/flutter ( 7210): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'Uint8List' is not a subtype of type 'String'
E/flutter ( 7210): #0      HttpClient._dioCatch
http.dart:18
E/flutter ( 7210): #1      HttpClient.multipartPost
http.dart:103
E/flutter ( 7210): <asynchronous suspension>
E/flutter ( 7210): #2      RawAPI.sendPhoto
raw_api.dart:388
E/flutter ( 7210): <asynchronous suspension>
E/flutter ( 7210): #3      BotFunctions._sendPhotos
bot_fun_core.dart:94
@HeySreelal
Copy link
Owner

Oops sorry! Nothing, just forgot to remove some testing things. Was blown out yesterday.

I've retracted the version on pub.dev, will update the code later today.

If you're interested feel free to shoot a PR.

@OttomanDeveloper
Copy link
Author

I haven't made any fork but older versions are making the same issue. Can you tell me how I can fix the issue?

@HeySreelal
Copy link
Owner

I'm extremely sorry for the inconveniences caused to you.

Can you check if v1.10.7 has this issue?

Reset assured, this will be fixed by tonight itself.

@OttomanDeveloper OttomanDeveloper changed the title When Sending Photo Using1 Bot("Token").api.sendPhoto Getting wired error. When Sending Photo Using1 Bot("Token").api.sendPhoto Getting weird error. Aug 16, 2023
@OttomanDeveloper OttomanDeveloper changed the title When Sending Photo Using1 Bot("Token").api.sendPhoto Getting weird error. "Encountering Unusual Error While Using Bot API's sendPhoto Method with Bot Token" Aug 16, 2023
@OttomanDeveloper OttomanDeveloper changed the title "Encountering Unusual Error While Using Bot API's sendPhoto Method with Bot Token" Encountering Unusual Error While Using Bot API's sendPhoto Method with Bot Token Aug 16, 2023
@OttomanDeveloper
Copy link
Author

I think the issue is resolved.

@HeySreelal
Copy link
Owner

In v1.10.7? Good to hear :)

Let's keep this issue opened for a while. I'll check this later today.

HeySreelal added a commit that referenced this issue Aug 16, 2023
@HeySreelal
Copy link
Owner

HeySreelal commented Aug 16, 2023

Hey, I just tried to make the error again. This is my code:

  bot.command('test', (ctx) async {
    await ctx.api.sendPhoto(
      ctx.id,
      InputFile.fromFile(
        File('example/assets/photo.jpeg'),
      ),
    );
  });

The code worked fine, and the photo message was sent. So, it's working even in the latest version? Otherwise, can you please share your code which threw the given exception?

@HeySreelal
Copy link
Owner

Hey @OttomanDeveloper - can you confirm if this bug exists in the dev branch? If it doesn't, I'd like to release a new version as soon as possible.

Kind regards :)

@OttomanDeveloper
Copy link
Author

In v1.10.7? Good to hear :)

Let's keep this issue opened for a while. I'll check this later today.

Yes, there's no issue in v1.10.7.

@OttomanDeveloper
Copy link
Author

Okay, I will check dev branch tomorrow and let you know.

@HeySreelal
Copy link
Owner

Thankss @OttomanDeveloper. I'll stand by.

@OttomanDeveloper
Copy link
Author

Hey, I just tried to make the error again. This is my code:

  bot.command('test', (ctx) async {
    await ctx.api.sendPhoto(
      ctx.id,
      InputFile.fromFile(
        File('example/assets/photo.jpeg'),
      ),
    );
  });

The code worked fine, and the photo message was sent. So, it's working even in the latest version? Otherwise, can you please share your code which threw the given exception?

I'm not sure why this issue started randomly yesterday, especially since the same version was working fine the day before. However, I followed your advice and downgraded to the version you recommended, v1.10.7.

@HeySreelal
Copy link
Owner

Hey, thanks! I rechecked it and found that it's not actually just with the sendPhoto method instead the code would break whenever an exception was thrown from the Telegram side - like sending a message to a blocked chat, etc.

Fixed it in 19f3e64

Thanks again for improving Televerse, feel free to report more issues if you find any. 🚀

@HeySreelal HeySreelal linked a pull request Aug 18, 2023 that will close this issue
@OttomanDeveloper
Copy link
Author

I appreciate it. I checked the problem, and it seems to be resolved now.

@HeySreelal
Copy link
Owner

Awesome!! Thanks for confirming ❤️

@HeySreelal HeySreelal added bug Something isn't working invalid This doesn't seem right labels Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants