This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
API model validation panics if properties
is nil/empty
#1820
Labels
properties
is nil/empty
#1820
Is this a request for help?:
Yes
Is this an ISSUE or FEATURE REQUEST? (choose one):
ISSUE
What version of acs-engine?:
ALL
If caller sends a PUT request with a missing/omitted
properties
field ACS Engine validation panics:E.g. of panic in: github.com\Azure\acs-engine\pkg\api\agentPoolOnlyApi\v20170831\validate.go (but happens for all API verisons)
Code snippet that panics:
if e := validate.Struct(a); e != nil {
return handleValidationErrors(e.(validator.ValidationErrors))
}
Further panic happens because of the following line but the code above only handles ValidationErrors and not InvalidValidationErrors. This is because
properties
is nil so it's not a valid struct:E.g. of sample PUT request:
Error message:
{ "code": "InternalOperationError", "message": "err: 'interface conversion: error is *validator.InvalidValidationError, not validator.ValidationErrors' stacktrace: 'goroutine 1990793 [running]:\nruntime/debug.Stack(0xc4209aad38, 0x556b1503af00, 0xc4201824c0)\n\t/usr/local/go/src/runtime/debug/stack.go:24 +0x7b\nacsrp/pkg/microsoft.com/containerservice/filter.ErrorHandling.func1(0xc420b93680)\n\t/tmp/go/src/acsrp/pkg/microsoft.com/containerservice/filter/errorhandling.go:28 +0x64\npanic(0x556b1503af00, 0xc4201824c0)\n\t/usr/local/go/src/runtime/panic.go:489 +0x2d3\nacsrp/vendor/github.com/Azure/acs-engine/pkg/api/agentPoolOnlyApi/v20170831.(*Properties).Validate(0x0, 0x15, 0x200)\n\t/tmp/go/src/acsrp/vendor/github.com/Azure/acs-engine/pkg/api/agentPoolOnlyApi/v20170831/validate.go:68 +0xc0\nacsrp/vendor/github.com/Azure/acs-engine/pkg/api.(*Apiloader).LoadContainerServiceForAgentPoolOnlyCluster(0xc4209ab148, 0xc4200f8c00, 0x15, 0x200, 0xc4207205e7, 0xa, 0x1, 0x9, 0x0, 0x0)\n\t/tmp/go/src/acsrp/vendor/github.com/Azure/acs-engine/pkg/api/apiloader.go:163 +0x220\nacsrp/pkg/microsoft.com/containerservice/server/operations/managedcluster.(*PutManagedClusterOperation).ValidateAndSaveGoalState(0xc4213120f0)\n\t/tmp/go/src/acsrp/pkg/microsoft.com/containerservice/server/operations/managedcluster/putmanagedcluster.go:95 +0xb6e\nacsrp/pkg/microsoft.com/containerservice/server/handlers.(*BaseHandler).ValidateAndPersistOperation(0xc42000e160, 0xc4204dcce0, 0x556b15a9a140, 0xc4213120f0)\n\t/tmp/go/src/acsrp/pkg/microsoft.com/containerservice/server/handlers/basehandler.go:31 +0x57\nacsrp/pkg/microsoft.com/containerservice/server/handlers.(*ManagedClusterManager).PutManagedClusterHandler(0xc42000e160, 0xc420820240, 0xc420b93680)\n\t/tmp/go/src/acsrp/pkg/microsoft.com/containerservice/server/handlers/managedclustermanager.go:69 +0x215\nacsrp/pkg/microsoft.com/containerservice/server/handlers.(*ManagedClusterManager).PutManagedClusterHandler-fm(0xc420820240, 0xc420b93680)\n\t/tmp/go/src/acsrp/cmd/containerservice/containerservice.go:502 +0x40\nacsrp/vendor/github.com/emicklei/go-restful.(*Container).dispatch.func6(0xc420820240, 0xc420b93680)\n\t/tmp/go/src/acsrp/vendor/github.com/emicklei/go-restful/container.go:267 +0x40\nacsrp/vendor/github.com/emicklei/go-restful.(*FilterChain).ProcessFilter(0xc420820330, 0xc420820240, 0xc420b93680)\n\t/tmp/go/src/acsrp/vendor/github.com/emicklei/go-restful/filter.go:21 +0x97\nacsrp/pkg/microsoft.com/containerservice/filter.ErrorHandling(0xc420820240, 0xc420b93680, 0xc420820330)\n\t/tmp/go/src/acsrp/pkg/microsoft.com/containerservice/filter/errorhandling.go:39 +0x67\nacsrp/vendor/github.com/emicklei/go-restful.(*FilterChain).ProcessFilter(0xc420820330, 0xc420820240, 0xc420b93680)\n\t/tmp/go/src/acsrp/vendor/github.com/emicklei/go-restful/filter.go:19 +0x6a\nacsrp/pkg/microsoft.com/containerservice/filter.Context(0xc420820240, 0xc420b93680, 0xc420820330)\n\t/tmp/go/src/acsrp/pkg/microsoft.com/containerservice/filter/context.go:43 +0x3af\nacsrp/vendor/github.com/emicklei/go-restful.(*FilterChain).ProcessFilter(0xc420820330, 0xc420820240, 0xc420b93680)\n\t/tmp/go/src/acsrp/vendor/github.com/emicklei/go-restful/filter.go:19 +0x6a\nacsrp/vendor/github.com/emicklei/go-restful.(*Container).dispatch(0xc4200f0000, 0x556b15aa1f80, 0xc420562e00, 0xc420383c00)\n\t/tmp/go/src/acsrp/vendor/github.com/emicklei/go-restful/container.go:269 +0x9c8\nacsrp/vendor/github.com/emicklei/go-restful.(*Container).(acsrp/vendor/github.com/emicklei/go-restful.dispatch)-fm(0x556b15aa1f80, 0xc420562e00, 0xc420383c00)\n\t/tmp/go/src/acsrp/vendor/github.com/emicklei/go-restful/container.go:120 +0x4a\nnet/http.HandlerFunc.ServeHTTP(0xc4209b7170, 0x556b15aa1f80, 0xc420562e00, 0xc420383c00)\n\t/usr/local/go/src/net/http/server.go:1942 +0x46\nnet/http.(*ServeMux).ServeHTTP(0x556b15b470e0, 0x556b15aa1f80, 0xc420562e00, 0xc420383c00)\n\t/usr/local/go/src/net/http/server.go:2238 +0x132\nnet/http.serverHandler.ServeHTTP(0xc42009b290, 0x556b15aa1f80, 0xc420562e00, 0xc420383c00)\n\t/usr/local/go/src/net/http/server.go:2568 +0x94\nnet/http.(*conn).serve(0xc4209c08c0, 0x556b15aa3640, 0xc420461740)\n\t/usr/local/go/src/net/http/server.go:1825 +0x614\ncreated by net/http.(*Server).Serve\n\t/usr/local/go/src/net/http/server.go:2668 +0x2d0\n'" }
The text was updated successfully, but these errors were encountered: