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

Bug Report: Visibility isn't JSON encodable #156

Open
pixelcmtd opened this issue Jun 22, 2023 · 1 comment
Open

Bug Report: Visibility isn't JSON encodable #156

pixelcmtd opened this issue Jun 22, 2023 · 1 comment
Assignees
Labels
bug Something isn't working untriaged

Comments

@pixelcmtd
Copy link

1. Current bug behavior

Unhandled exception:
Converting object to an encodable object failed: Instance of 'Visibility'
#0      _JsonStringifier.writeObject (dart:convert/json.dart:793:7)
#1      _JsonStringifier.writeMap (dart:convert/json.dart:874:7)
#2      _JsonStringifier.writeJsonValue (dart:convert/json.dart:829:21)
#3      _JsonStringifier.writeObject (dart:convert/json.dart:784:9)
#4      _JsonStringStringifier.printOn (dart:convert/json.dart:982:17)
#5      _JsonStringStringifier.stringify (dart:convert/json.dart:967:5)
#6      JsonEncoder.convert (dart:convert/json.dart:345:30)
#7      JsonCodec.encode (dart:convert/json.dart:231:45)
#8      jsonEncode (dart:convert/json.dart:114:10)
#9      ServiceHelper.post (package:mastodon_api/src/core/service_helper.dart:167:23)
#10     BaseService.post (package:mastodon_api/src/service/base_service.dart:166:21)
#11     _StatusesV1Service.createStatus (package:mastodon_api/src/service/v1/statuses/statuses_v1_service.dart:876:21)
#12     main (redacted.dart)
#13     _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:294:33)
#14     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12)

2. Expected behavior

The code should just work (i.e. post a toot)

3. Steps to reproduce

import 'package:mastodon_api/mastodon_api.dart';

// the bulk of this is straight copy-paste from the example in the readme
void main(List<String> args) async {
  final mastodon = MastodonApi(
    instance: args[0],
    bearerToken: args[1],

    retryConfig: RetryConfig(
      maxAttempts: 5,
      jitter: Jitter(
        minInSeconds: 2,
        maxInSeconds: 5,
      ),
      onExecute: (event) => print(
        'Retry after ${event.intervalInSeconds} seconds... '
        '[${event.retryCount} times]',
      ),
    ),
  );

  try {
    final response = await mastodon.v1.statuses.createStatus(
      text: 'Toot!',
      visibility: Visibility.private,
    );

    print(response.rateLimit);
    print(response.data);
  } on UnauthorizedException catch (e) {
    print(e);
  } on RateLimitExceededException catch (e) {
    print(e);
  } on MastodonException catch (e) {
    print(e.response);
    print(e.body);
    print(e);
  }
}
  mastodon_api: ^0.6.1
@pixelcmtd pixelcmtd added bug Something isn't working untriaged labels Jun 22, 2023
@github-actions
Copy link

Thanks for your contribution! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working untriaged
Projects
None yet
Development

No branches or pull requests

2 participants