question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dart-dio-next: DioError [DioErrorType.other]: FormatException: Invalid HTTP header field value

See original GitHub issue

[dart-dio-next] Error on setting header object

Description

Header json objects are allowed. I am trying to send in a header object that’s defined in the openapi spec. Here’s the api side.

createRegistrationCode:
  get:
    summary: Get a registration code for adding a new player
    operationId: createRegistrationCode
    parameters:
      - in: header
        name: tracer
        schema:
          $ref: '../common/models/tracer.yaml#/Tracer'
    responses:
      '200': ...

I am generating the dart-dio-next client and setting the object without any complaints. However, when I run it, I get the following error. That’s the complete object I am sending. Note that the '\n’s are pasted as is - that’s not my intervention.

flutter: DioError [DioErrorType.other]: FormatException: Invalid HTTP header field value: "Tracer {\n  tracerId=TracerId {\n    userId=_user_,\n    timestamp=1640694471654,\n    sequence=1,\n    deviceInstanceId=Wiyhnm,\n  },\n  taskName=RegistrationCubit: Fetching data,\n  traces=[Trace {\n    timestamp=1640694471654,\n    subTaskName=RegistrationCubit: Fetching data,\n    message=,\n    traceState=start,\n  }, Trace {\n    timestamp=1640694471656,\n    subTaskName=CreateRegistrationCodeRepoImpl: createRegistrationCode,\n    message=,\n    traceState=start,\n  }],\n  metrics=[],\n  deviceDetails=DeviceDetails {\n    installationType=web,\n    deviceInfo=,\n  },\n}" (at character 9)
Tracer {
        ^
openapi-generator version

latest generator - 5.3.0

Let me know what I can do. Thanks.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kuhnroyalcommented, Apr 18, 2022

If you want to transmit objects as headers, you probably need an opinionated serialization mechanism on client and server. This is nothing we can provide out of the box.

1reaction
srix55commented, Apr 18, 2022

Hi @kuhnroyal it looks like headers are supposed to be strings. Even if I make custom objects out of it in my openAPI specs, the web server implementations with RestEasy complain on it. The error “Invalid HTTP header field value” is right. I guess the OpenAPI specs definition should not be saying that headers can be custom objects. I’m closing this error. Thanks for looking into it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalid HTTP header field value in flutter - Stack Overflow
I receive this error Unhandled Exception: FormatException: Invalid HTTP header field when my header value contain accent: village_name=moapé ...
Read more >
FormatException Invalid HTTP header Flutter on iOS-Flutter
According to RFC 2616, HTTP headers must only include characters in ISO-8859-1, unless they are encoded in a MIME format, which might look...
Read more >
Invalid HTTP header field value in flutter - Zeste de Savoir
Lorsque j'ajoute les cookies dans le header j'obtiens cette erreur Unhandled Exception: FormatException: Invalid HTTP header field.
Read more >
Invalid HTTP header field value in flutter - Anycodings.com
I create a function use anycodings_flutter uri.encodecomponent to solve my problem anycodings_flutter this my code: convert(value){ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found