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

Invalid generation when using --force-pointers with required headers #262

Closed
TheSadlig opened this issue Dec 10, 2024 · 2 comments
Closed

Comments

@TheSadlig
Copy link
Contributor

TheSadlig commented Dec 10, 2024

Hi there,

Where using the flag --force-pointers , with headers that are required, the generated code will be invalid.

Example yaml:

asyncapi: 2.6.0
info:
  title: Sample App
  version: 1.2.3
components:
  messages:
    Test:
      headers:
        type: object
        required:
          - correlationId
        properties:
          correlationId:
            description: Correlation ID set by user
            type: string
      payload:
        type: string

Generates:

// brokerMessageToTestMessage
switch {
case k == "correlationId": // Retrieving CorrelationId header
	msg.Headers.CorrelationId = string(v) // <-- v is a pointer here, so it won't work
default:

}
...

// toBrokerMessage
headers["correlationId"] = []byte(msg.Headers.CorrelationId) // <-- msg.Headers.CorrelationId is a pointer here, so it won't work

This only happens if the following conditions are present:

  • Flag --force-pointers is used
  • Headers are presents
  • Headers are required

I'll see if this can be fixed easily.

Thanks,
TheSadlig

@lerenn
Copy link
Owner

lerenn commented Jan 20, 2025

Thanks @TheSadlig for pointing out this and writing a PR :)

I'll check that right away (and sorry again for the late response)

@lerenn
Copy link
Owner

lerenn commented Jan 20, 2025

PR merged, thanks again :)

@lerenn lerenn closed this as completed Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants