apache / camel-k

Apache Camel K is a lightweight integration platform, born on Kubernetes, with serverless superpowers
https://camel.apache.org/camel-k
Apache License 2.0
868 stars 349 forks source link

fix(trait): use a configmap index #5948

Closed squakez closed 1 day ago

squakez commented 5 days ago

Closes #5924

Release Note

fix(trait): use a configmap index
squakez commented 5 days ago

fyi @hernanDatgDev I've tested this against your reproducer and it seems the root issue is fixed. Please, have a look.

hernanDatgDev commented 3 days ago

@squakez I pulled your fork and built the project locally. For some reason I'm getting a rest dsl plugin failure when my integration is building. I've been struggling with the root cause. Is there some difference between v2.4 and 2.5 RE how the project is built or the api spec that's required for this to work? I feel like I must be missing something obvious.

{"level":"error","ts":"2024-11-19T03:31:47Z","logger":"camel-k.maven.build","msg":"Failed to execute goal org.apache.camel.k:camel-k-maven-plugin:3.15.0:generate-rest-xml (default) on project camel-k-rest-d │
│ sl-generator: Exception while generating rest xml: Cannot invoke \"io.swagger.v3.oas.models.media.Content.entrySet()\" because the return value of \"io.swagger.v3.oas.models.responses.ApiResponse.getContent()\" is null -> [Help 1]","stac │
│ ktrace":"github.com/apache/camel-k/v2/pkg/util/log.Logger.Error\n\tgithub.com/apache/camel-k/v2/pkg/util/log/log.go:80\ngithub.com/apache/camel-k/v2/pkg/util/maven.normalizeLog\n\tgithub.com/apache/camel-k/v2/pkg/util/maven/maven_log.go: │
│ 87\ngithub.com/apache/camel-k/v2/pkg/util/maven.LogHandler\n\tgithub.com/apache/camel-k/v2/pkg/util/maven/maven_log.go:53\ngithub.com/apache/camel-k/v2/pkg/util.scan\n\tgithub.com/apache/camel-k/v2/pkg/util/command.go:76\ngithub.com/apac │
│ he/camel-k/v2/pkg/util.RunAndLog.func1\n\tgithub.com/apache/camel-k/v2/pkg/util/command.go:55\ngolang.org/x/sync/errgroup.(*Group).Go.func1\n\tgolang.org/x/sync@v0.9.0/errgroup/errgroup.go:78"}

For reference here's the api spec I'm including in my referenced configmap:

    openapi: 3.0.3
    info:
      title: Basic API
      version: "1.0"
    paths:
      /test:
        post:
          operationId: test
          responses:
            200:
              description: Default response
      /user/{userId}:
        get:
          operationId: getUser
          parameters:
            - name: userId
              in: path
              required: true
              schema:
                type: string
          responses:
            200:
              description: Default response
squakez commented 2 days ago

Hi @hernanDatgDev, please, let's stick to the original reproducer reported in https://github.com/apache/camel-k/issues/5924#issuecomment-2463315268 to avoid mixing up things. I've removed the response content and I manage to reproduce your same problem with runtime 3.15.0 (Camel core 4.8.0). However, this is a different problem from the one we're fixing in this PR.

I've run the same reproducer against runtime 3.8.1 and the issue is not appearing, so, there is some regression or new behavior introduced in the new Camel core 4.8.0. From Camel K perspective we can't really do anything until that is fixed in the core unfortunately. I suggest you please open an issue and report this in the core. It also may be a core fix, given that we may expect a response to always provide a content, but I am not into openapi spec details to confirm that.

As for this PR, please, feel free to have a look and verify if the original issue is solved, so I can merge accordingly.

squakez commented 2 days ago

It could be caused by the removal of a swagger validator [1] or even the upgrade of swagger dependencies which may be adding now some validation to avoid such value to be empty.

https://camel.apache.org/manual/camel-4x-upgrade-guide-4_6.html#_camel_rest_openapi

hernanDatgDev commented 2 days ago

@squakez Yes you're right there is some additional validation on the openapi spec and it expects certain parts to be present. I made the necessary changes and got the expected behavior. I also got the expected behavior with the original files I provided in my ticket. The changes made seem good to me so far 👍