This is an automated email from the ASF dual-hosted git repository.
AlinsRan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git
The following commit(s) were added to refs/heads/master by this push:
new 44565558 fix: Ingress with ImplementationSpecific path panics when
annotations are empty (#2780)
44565558 is described below
commit 44565558a2f53da02bf5b75d013ae6abbd50d79f
Author: Rushen Wang <[email protected]>
AuthorDate: Mon Jun 15 15:05:45 2026 +0800
fix: Ingress with ImplementationSpecific path panics when annotations are
empty (#2780)
Signed-off-by: wangrushen <[email protected]>
---
internal/adc/translator/ingress.go | 2 +-
internal/adc/translator/ingress_test.go | 78 +++++++++++++++++++++++++++++++++
2 files changed, 79 insertions(+), 1 deletion(-)
diff --git a/internal/adc/translator/ingress.go
b/internal/adc/translator/ingress.go
index c1bae046..4b6abf79 100644
--- a/internal/adc/translator/ingress.go
+++ b/internal/adc/translator/ingress.go
@@ -282,7 +282,7 @@ func (t *Translator) buildRouteFromIngressPath(
prefix := strings.TrimSuffix(path.Path, "/") + "/*"
uris = append(uris, prefix)
case networkingv1.PathTypeImplementationSpecific:
- if config.UseRegex {
+ if config != nil && config.UseRegex {
uris = []string{"/*"}
vars := apiv2.ApisixRouteHTTPMatchExprs{
apiv2.ApisixRouteHTTPMatchExpr{
diff --git a/internal/adc/translator/ingress_test.go
b/internal/adc/translator/ingress_test.go
new file mode 100644
index 00000000..70cca09f
--- /dev/null
+++ b/internal/adc/translator/ingress_test.go
@@ -0,0 +1,78 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package translator
+
+import (
+ "testing"
+
+ "github.com/go-logr/logr"
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
+ corev1 "k8s.io/api/core/v1"
+ networkingv1 "k8s.io/api/networking/v1"
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/apimachinery/pkg/types"
+
+ "github.com/apache/apisix-ingress-controller/internal/provider"
+)
+
+func TestTranslateIngress_ImplementationSpecificPathWithoutAnnotations(t
*testing.T) {
+ translator := NewTranslator(logr.Discard(), "")
+ pathType := networkingv1.PathTypeImplementationSpecific
+
+ ingress := &networkingv1.Ingress{
+ ObjectMeta: metav1.ObjectMeta{
+ Namespace: "default",
+ Name: "test-ingress",
+ },
+ Spec: networkingv1.IngressSpec{
+ Rules: []networkingv1.IngressRule{{
+ Host: "example.com",
+ IngressRuleValue:
networkingv1.IngressRuleValue{HTTP: &networkingv1.HTTPIngressRuleValue{
+ Paths: []networkingv1.HTTPIngressPath{{
+ Path: "/api/(.*)",
+ PathType: &pathType,
+ Backend:
networkingv1.IngressBackend{
+ Service:
&networkingv1.IngressServiceBackend{
+ Name:
"test-svc",
+ Port:
networkingv1.ServiceBackendPort{Number: 80},
+ },
+ },
+ }},
+ }},
+ }},
+ },
+ }
+
+ tctx := &provider.TranslateContext{
+ Services: map[types.NamespacedName]*corev1.Service{
+ {Namespace: "default", Name: "test-svc"}: {
+ ObjectMeta: metav1.ObjectMeta{Namespace:
"default", Name: "test-svc"},
+ Spec: corev1.ServiceSpec{Ports:
[]corev1.ServicePort{{Port: 80}}},
+ },
+ },
+ }
+
+ result, err := translator.TranslateIngress(tctx, ingress)
+ require.NoError(t, err)
+ require.Len(t, result.Services, 1)
+
+ route := result.Services[0].Routes[0]
+ assert.Equal(t, []string{"/api/(.*)"}, route.Uris)
+ assert.Empty(t, route.Vars)
+}