You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "dovics (via GitHub)" <gi...@apache.org> on 2026/06/03 01:12:09 UTC

[PR] fix: Ingress with ImplementationSpecific path panics when annotations… [apisix-ingress-controller]

dovics opened a new pull request, #2780:
URL: https://github.com/apache/apisix-ingress-controller/pull/2780

   … are empty
   
   <!-- Please answer these questions before submitting a pull request -->
   
   ### Type of change:
   
   <!-- Please delete options that are not relevant. -->
   
   <!-- Select all the options from below that matches the type your PR best -->
   
   - [x] Bugfix
   
   ### What this PR does / why we need it:
   
   <!--- Why is this change required? What problem does it solve? -->
   <!--- If it fixes an open issue, please link to the issue here. -->
   This PR fixes a panic when translating an Ingress that has no annotations and uses `pathType: ImplementationSpecific`.
   
     `TranslateIngressAnnotations()` returns `nil` when the Ingress has no annotations. Before this change, the Ingress translator directly accessed `config.UseRegex` while handling
     `PathTypeImplementationSpecific`, which caused a nil pointer dereference.
   
     This change adds a nil check before reading `UseRegex`, so an Ingress without annotations is translated safely. Regex matching is still enabled only when the `k8s.apisix.apache.org/use-regex` annotation is
     present and set to `true`.
   
   ### Pre-submission checklist:
   
   <!--
   Please follow the requirements:
   1. Use Draft if the PR is not ready to be reviewed
   2. Test is required for the feat/fix PR, unless you have a good reason
   3. Doc is required for the feat PR
   4. Use a new commit to resolve review instead of `push -f`
   5. Use "request review" to notify the reviewer once you have resolved the review
   -->
   
     - [x] Did you explain what problem does this PR solve? Or what new features have been added?
     - [ ] Have you added corresponding test cases?
     - [ ] Have you modified the corresponding document?
     - [x] Is this PR backward compatible?(https://github.com/apache/apisix-ingress-controller#community) first**
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: Ingress with ImplementationSpecific path panics when annotations… [apisix-ingress-controller]

Posted by "dovics (via GitHub)" <gi...@apache.org>.
dovics commented on PR #2780:
URL: https://github.com/apache/apisix-ingress-controller/pull/2780#issuecomment-4627671069

   add regression tests
   
   before fix
   ```
   go test -v ./internal/adc/translator/ -run TestTranslateIngress_ImplementationSpecificPathWithoutAnnotations
   === RUN   TestTranslateIngress_ImplementationSpecificPathWithoutAnnotations
   --- FAIL: TestTranslateIngress_ImplementationSpecificPathWithoutAnnotations (0.00s)
   panic: runtime error: invalid memory address or nil pointer dereference [recovered, repanicked]
   [signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0x1500c62]
   
   goroutine 54 [running]:
   testing.tRunner.func1.2({0x16aec40, 0x27d5fd0})
           /usr/local/go/src/testing/testing.go:1872 +0x237
   testing.tRunner.func1()
           /usr/local/go/src/testing/testing.go:1875 +0x35b
   panic({0x16aec40?, 0x27d5fd0?})
           /usr/local/go/src/runtime/panic.go:783 +0x132
   github.com/apache/apisix-ingress-controller/internal/adc/translator.(*Translator).buildRouteFromIngressPath(0xc0001b1200, 0xc0000a4cd8, 0xc000204f20, 0xc0001b12c0, 0x0, {0xc000014310, 0x3}, 0xc0001b1290)
           /home/dovics/workspace/insightst/apisix-ingress-controller/internal/adc/translator/ingress.go:285 +0x342
   github.com/apache/apisix-ingress-controller/internal/adc/translator.(*Translator).buildServiceFromIngressPath(0xc0001b1200, 0xc00043bcd8, 0xc000204f20, 0x0, 0xc0001b12c0, {0xc000014310, 0x3}, {0xc0002a38d0, 0x1, 0x1}, ...)
           /home/dovics/workspace/insightst/apisix-ingress-controller/internal/adc/translator/ingress.go:165 +0x33e
   github.com/apache/apisix-ingress-controller/internal/adc/translator.(*Translator).TranslateIngress(0xc0001b1200, 0xc00043bcd8, 0xc000204f20)
           /home/dovics/workspace/insightst/apisix-ingress-controller/internal/adc/translator/ingress.go:107 +0x49a
   github.com/apache/apisix-ingress-controller/internal/adc/translator.TestTranslateIngress_ImplementationSpecificPathWithoutAnnotations(0xc0000d8c40)
           /home/dovics/workspace/insightst/apisix-ingress-controller/internal/adc/translator/ingress_test.go:71 +0x37a
   testing.tRunner(0xc0000d8c40, 0x19a9e00)
           /usr/local/go/src/testing/testing.go:1934 +0xea
   created by testing.(*T).Run in goroutine 1
           /usr/local/go/src/testing/testing.go:1997 +0x465
   FAIL    github.com/apache/apisix-ingress-controller/internal/adc/translator     0.020s
   FAIL
   ```
   
   after fix
   ```
   go test -v ./internal/adc/translator/ -run TestTranslateIngress_ImplementationSpecificPathWithoutAnnotations
   === RUN   TestTranslateIngress_ImplementationSpecificPathWithoutAnnotations
   --- PASS: TestTranslateIngress_ImplementationSpecificPathWithoutAnnotations (0.00s)
   PASS
   ok      github.com/apache/apisix-ingress-controller/internal/adc/translator     0.019s
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: Ingress with ImplementationSpecific path panics when annotations… [apisix-ingress-controller]

Posted by "AlinsRan (via GitHub)" <gi...@apache.org>.
AlinsRan merged PR #2780:
URL: https://github.com/apache/apisix-ingress-controller/pull/2780


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org