Skip to content

[BUG] [Dart] API Responses incorrectly use .body instead of .bodyBytes when checking emptiness, which can crash for non-ut8 data #17546

@0xNF

Description

@0xNF

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
openapi-generator version

7.3.0-snapshot

    if (_response.body.isNotEmpty && _response.statusCode != HttpStatus.noContent) {
      return await apiClient.deserializeAsync(
        await _decodeBodyBytes(_response),
        'OutputFormat',
      ) as OutputFormat;
    }

the .body method implicitly converts to utf-8, which will throw exceptions when the data isn't a utf-8 string. Instead, when checking for emptiness, .bodyBytes should be used instead.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions