Skip to content

Commit

Permalink
Set max size for upload
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubno committed Nov 10, 2023
1 parent c14bbef commit 85a568b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2604,6 +2604,7 @@ golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o=
golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU=
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
golang.org/x/term v0.14.0 h1:LGK9IlZ8T9jvdy6cTdfKUCltatMFOehAQo9SRC46UQ8=
golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww=
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
Expand Down
16 changes: 10 additions & 6 deletions packages/api/internal/handlers/envs.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,18 @@ func (a *APIStore) PostEnvs(c *gin.Context) {
}

dockerfile := c.PostForm("dockerfile")
alias, err := utils.CleanEnvID(c.PostForm("alias"))
if err != nil {
a.sendAPIStoreError(c, http.StatusBadRequest, fmt.Sprintf("Invalid alias: %s", alias))
alias := c.PostForm("alias")

err = fmt.Errorf("invalid alias: %w", err)
telemetry.ReportCriticalError(ctx, err)
if alias != "" {
alias, err = utils.CleanEnvID(alias)
if err != nil {
a.sendAPIStoreError(c, http.StatusBadRequest, fmt.Sprintf("Invalid alias: %s", alias))

return
err = fmt.Errorf("invalid alias: %w", err)
telemetry.ReportCriticalError(ctx, err)

return
}
}

properties := a.GetPackageToPosthogProperties(&c.Request.Header)
Expand Down
6 changes: 3 additions & 3 deletions packages/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (

const (
serviceName = "orchestration-api"
maxMultipartMemory = 1 << 28 // 256 MiB
maxUploadLimit = 1 << 30 // 1 GiB
maxMultipartMemory = 1 << 27 // 128 MiB
maxUploadLimit = 1 << 28 // 256 MiB
)

var ignoreLoggingForPaths = []string{"/health"}
Expand Down Expand Up @@ -84,7 +84,7 @@ func NewGinServer(apiStore *handlers.APIStore, swagger *openapi3.T, port int) *h
AuthenticationFunc: AuthenticationFunc,
},
}),
limits.RequestSizeLimiter(maxMultipartMemory),
limits.RequestSizeLimiter(maxUploadLimit),
)

// We now register our store above as the handler for the interface
Expand Down

0 comments on commit 85a568b

Please sign in to comment.