seal-io / walrus

Walrus is an open-source application management platform based on IaC tools including OpenTofu, Terraform and others. It helps platform engineers build golden paths for developers and empowers developers with self-service capabilities.
Apache License 2.0
428 stars 42 forks source link

Panic when rolling back service revision with an invalid service id #833

Closed Finenyaco closed 7 months ago

Finenyaco commented 1 year ago

Version: main
UI: dev-61685c0 Commit ID: 05c9cec0b0e073b3b14292f1f4f90789c74f1f02 Env: Ubuntu 22.04 amd64, aws EC2

Test Steps:

  1. Send an api request with an invalid service id to roll back service revision. (service id is service revision id) image

Test Result:

  1. Panic occurred: invalid memory address or nil pointer dereference
    
    2023-06-26T02:01:59.977Z    E   api panic observing: runtime error: invalid memory address or nil pointer dereference, callstack:
    runtime.panicmem
    runtime/panic.go:260 (0x450fb5)
    runtime.sigpanic
    runtime/signal_unix.go:839 (0x450f85)
    github.com/seal-io/seal/pkg/apis/service/view.(*RouteRollbackRequest).ValidateWith
    github.com/seal-io/seal/pkg/apis/service/view/io.go:485 (0x462781d)
    github.com/seal-io/seal/pkg/apis/runtime.RouteResource.func1
    github.com/seal-io/seal/pkg/apis/runtime/routes.go:496 (0x12c2701)
    github.com/gin-gonic/gin.(*Context).Next
    github.com/gin-gonic/gin@v1.9.0/context.go:174 (0x448b702)
    github.com/seal-io/seal/pkg/auths.Account.Filter
    github.com/seal-io/seal/pkg/auths/account.go:61 (0x448b6e6)
    github.com/gin-gonic/gin.(*Context).Next
    github.com/gin-gonic/gin@v1.9.0/context.go:174 (0x12bdf42)
    github.com/seal-io/seal/pkg/apis/runtime.RequestThrottling.func2
    github.com/seal-io/seal/pkg/apis/runtime/middleware_flowcontrol.go:86 (0x12bdeed)
    github.com/gin-gonic/gin.(*Context).Next
    github.com/gin-gonic/gin@v1.9.0/context.go:174 (0x12be577)
    github.com/seal-io/seal/pkg/apis/runtime.I18n.func1
    github.com/seal-io/seal/pkg/apis/runtime/middleware_i18n.go:28 (0x12be55e)
    github.com/gin-gonic/gin.(*Context).Next
    github.com/gin-gonic/gin@v1.9.0/context.go:174 (0x12bc0be)
    github.com/seal-io/seal/pkg/apis/runtime.Erroring.func1
    github.com/seal-io/seal/pkg/apis/runtime/middleware_error.go:22 (0x12bc0a6)
    github.com/gin-gonic/gin.(*Context).Next
    github.com/gin-gonic/gin@v1.9.0/context.go:174 (0x12beaec)
    github.com/seal-io/seal/pkg/apis/runtime.Recovering.func1
    github.com/seal-io/seal/pkg/apis/runtime/middleware_recovery.go:44 (0x12bead8)
    github.com/gin-gonic/gin.(*Context).Next
    github.com/gin-gonic/gin@v1.9.0/context.go:174 (0x12bf482)
    github.com/seal-io/seal/pkg/apis/runtime.Logging.func2
    github.com/seal-io/seal/pkg/apis/runtime/middleware_route.go:80 (0x12bf45f)
    github.com/gin-gonic/gin.(*Context).Next
    github.com/gin-gonic/gin@v1.9.0/context.go:174 (0x1240e50)
    github.com/gin-gonic/gin.(*Engine).handleHTTPRequest
    github.com/gin-gonic/gin@v1.9.0/gin.go:620 (0x1240ab8)
    github.com/gin-gonic/gin.(*Engine).ServeHTTP
    github.com/gin-gonic/gin@v1.9.0/gin.go:576 (0x12405fc)
    net/http.serverHandler.ServeHTTP
    net/http/server.go:2947 (0x7811eb)
    net/http.initALPNRequest.ServeHTTP
    net/http/server.go:3556 (0x784364)
    net/http.(*http2serverConn).runHandler
    net/http/h2_bundle.go:5910 (0x754617)
    runtime.goexit
    runtime/asm_amd64.s:1594 (0x46e920)

github.com/seal-io/seal/pkg/apis/runtime.Recovering.func1.1 github.com/seal-io/seal/pkg/apis/runtime/middleware_recovery.go:30 runtime.gopanic runtime/panic.go:884 runtime.panicmem runtime/panic.go:260 runtime.sigpanic runtime/signal_unix.go:839 github.com/seal-io/seal/pkg/apis/service/view.(RouteRollbackRequest).ValidateWith github.com/seal-io/seal/pkg/apis/service/view/io.go:485 github.com/seal-io/seal/pkg/apis/runtime.RouteResource.func1 github.com/seal-io/seal/pkg/apis/runtime/routes.go:496 github.com/gin-gonic/gin.(Context).Next github.com/gin-gonic/gin@v1.9.0/context.go:174 github.com/seal-io/seal/pkg/auths.Account.Filter github.com/seal-io/seal/pkg/auths/account.go:61 github.com/gin-gonic/gin.(Context).Next github.com/gin-gonic/gin@v1.9.0/context.go:174 github.com/seal-io/seal/pkg/apis/runtime.RequestThrottling.func2 github.com/seal-io/seal/pkg/apis/runtime/middleware_flowcontrol.go:86 github.com/gin-gonic/gin.(Context).Next github.com/gin-gonic/gin@v1.9.0/context.go:174 github.com/seal-io/seal/pkg/apis/runtime.I18n.func1 github.com/seal-io/seal/pkg/apis/runtime/middleware_i18n.go:28 github.com/gin-gonic/gin.(Context).Next github.com/gin-gonic/gin@v1.9.0/context.go:174 github.com/seal-io/seal/pkg/apis/runtime.Erroring.func1 github.com/seal-io/seal/pkg/apis/runtime/middleware_error.go:22 github.com/gin-gonic/gin.(Context).Next github.com/gin-gonic/gin@v1.9.0/context.go:174 github.com/seal-io/seal/pkg/apis/runtime.Recovering.func1 github.com/seal-io/seal/pkg/apis/runtime/middleware_recovery.go:44 github.com/gin-gonic/gin.(Context).Next github.com/gin-gonic/gin@v1.9.0/context.go:174 github.com/seal-io/seal/pkg/apis/runtime.Logging.func2 github.com/seal-io/seal/pkg/apis/runtime/middleware_route.go:80 github.com/gin-gonic/gin.(Context).Next github.com/gin-gonic/gin@v1.9.0/context.go:174 github.com/gin-gonic/gin.(Engine).handleHTTPRequest github.com/gin-gonic/gin@v1.9.0/gin.go:620 github.com/gin-gonic/gin.(Engine).ServeHTTP github.com/gin-gonic/gin@v1.9.0/gin.go:576 net/http.serverHandler.ServeHTTP net/http/server.go:2947 net/http.initALPNRequest.ServeHTTP net/http/server.go:3556 net/http.(*http2serverConn).runHandler net/http/h2_bundle.go:5910 2023-06-26T02:01:59.977Z D api 500 | HTTP/2.0 | 51 B | 5.517657ms | 183.14.134.31 | POST /v1/services/466767349538619394/rollback?projectID=466686076812001282&revisionID=466767349538619394

Finenyaco commented 7 months ago

Environment

Test Result:

Send a POST request as follows:

https://localhost/v1/projects/501120921004734210/environments/501120921038288642/resources/501288191609851650/rollback?revisionID=501288191609851650

Check the response, cannot be reprodueced:

{
    "message": "model: resource not found",
    "status": 404,
    "statusText": "Not Found"
}