Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
95dfbd0
corrected api specs
prkhrkat May 30, 2025
02eacc9
specs enhance
prkhrkat Jul 25, 2025
d5b9a1c
Merge branch 'develop' into api-specs
prkhrkat Jul 25, 2025
15b2a4f
develop-merge
prkhrkat Jul 31, 2025
cdd8421
corrected specs
prkhrkat Aug 4, 2025
b35c605
corrected specs
prkhrkat Aug 4, 2025
de7ae84
vendor for spec-validator
prkhrkat Aug 4, 2025
8663138
spec-fixes as per cursor when ran on results file
prkhrkat Aug 4, 2025
51a4b66
Merge branch 'api-specs' into feat-api-spec-validator
prkhrkat Aug 4, 2025
c4883f4
spec-fixes manually for /orchestrator path
prkhrkat Aug 4, 2025
4338a20
script fix to run against server
prkhrkat Aug 4, 2025
172e69d
naming changed from devtron-lab
prkhrkat Aug 4, 2025
5cbb17c
removed extra code
prkhrkat Aug 5, 2025
d51bf31
framework.go update
prkhrkat Aug 5, 2025
67387e6
api-spec fix
prkhrkat Aug 5, 2025
0f04a1c
spec fix
prkhrkat Aug 5, 2025
2c92037
script fix
prkhrkat Aug 5, 2025
413fa68
devops specs included
prkhrkat Aug 7, 2025
e9e0752
script fix
prkhrkat Aug 7, 2025
fa1ded1
script fix
prkhrkat Aug 8, 2025
b6be5db
specs fix
prkhrkat Aug 13, 2025
abd5cce
redocly script to generate html
prkhrkat Aug 13, 2025
d759500
refact
prkhrkat Aug 13, 2025
62ee1a8
refact
prkhrkat Aug 13, 2025
d810f04
refact
prkhrkat Aug 13, 2025
52dfab2
doc: api spec merger
SATYAsasini Aug 13, 2025
603927d
chore: test commit
SATYAsasini Aug 13, 2025
790c574
misc: script name rectified in action file
SATYAsasini Aug 13, 2025
e752b44
misc: testing change in /spec
SATYAsasini Aug 13, 2025
a1ee5ca
misc: test commit
SATYAsasini Aug 13, 2025
2edbf16
misc: test commit
SATYAsasini Aug 13, 2025
e7ac045
refact
prkhrkat Aug 13, 2025
88eb2a2
refact
prkhrkat Aug 13, 2025
f578cd2
refact
prkhrkat Aug 13, 2025
436dfd9
refact
prkhrkat Aug 13, 2025
f5169ad
feat: action fix and resource recommender specs
SATYAsasini Aug 13, 2025
0e616bc
Merge branch 'feat-api-spec-validator' of https://github.com/devtron-…
SATYAsasini Aug 13, 2025
017f106
fix: action fixes
SATYAsasini Aug 13, 2025
1a13e85
chore: test trigger commit
SATYAsasini Aug 13, 2025
8a89675
chore: test run commit
SATYAsasini Aug 14, 2025
b6db917
chore: test commit
SATYAsasini Aug 14, 2025
3ae63e5
chore: test commit
SATYAsasini Aug 14, 2025
a6bfb94
feat: git push job in action file
SATYAsasini Aug 14, 2025
fd03bc1
feat: git push job in action file
SATYAsasini Aug 14, 2025
73124a9
chore: test commit
SATYAsasini Aug 14, 2025
4fc825c
chore: test commit
SATYAsasini Aug 14, 2025
041bf25
chore: test commit
SATYAsasini Aug 14, 2025
2da6a86
chore: test commit
SATYAsasini Aug 14, 2025
1e272f6
chore: test commit
SATYAsasini Aug 14, 2025
1145251
chore: test commit
SATYAsasini Aug 14, 2025
347138a
chore: test commit
SATYAsasini Aug 14, 2025
8398148
fix: script misc chore fixes and trigger commit
SATYAsasini Aug 14, 2025
f64222a
fix: script fixes
SATYAsasini Aug 14, 2025
9ad2dca
fix: script fixes
SATYAsasini Aug 14, 2025
b94d5a8
fix: script fixes
SATYAsasini Aug 14, 2025
32a9759
fix: script fixes
SATYAsasini Aug 14, 2025
fb17b6f
fix: script fixes
SATYAsasini Aug 14, 2025
9a66ab0
fix: script fixes
SATYAsasini Aug 14, 2025
6ab5ee2
fix: script fixes
SATYAsasini Aug 14, 2025
9c7d32b
Merge branch 'develop' into feat-api-spec-validator
prkhrkat Aug 17, 2025
92f52b3
create API token validation
prkhrkat Aug 18, 2025
dfc7ee6
Merge remote-tracking branch 'origin/feat-api-spec-validator' into fe…
prkhrkat Aug 18, 2025
696d440
refact
prkhrkat Aug 18, 2025
d18e91f
refact
prkhrkat Aug 18, 2025
cf3cdbe
security policy specs fixed
prkhrkat Aug 18, 2025
5401c63
refact
prkhrkat Aug 18, 2025
2bfb2b7
refact
prkhrkat Aug 19, 2025
50125b8
refact
prkhrkat Aug 19, 2025
e271a87
refact
prkhrkat Aug 19, 2025
47267c8
refact
prkhrkat Aug 19, 2025
66a85b1
refact
prkhrkat Aug 19, 2025
0667df9
fix: API token generation api responses refactoring
SATYAsasini Aug 19, 2025
3a5e199
fix: register custom validation against tag for api token name valida…
SATYAsasini Aug 20, 2025
7593c27
fix: register custom validation against tag for api token name valida…
SATYAsasini Aug 20, 2025
01df986
Revert "fix: register custom validation against tag for api token nam…
SATYAsasini Aug 20, 2025
1bcb953
fix: remove `required` validation from Description and expiryAtInMs
SATYAsasini Aug 20, 2025
a3da1fd
fix: adding resource conflict api response in WriteJsonResp utility
SATYAsasini Aug 20, 2025
8deb394
ent separation
prkhrkat Aug 20, 2025
6ebb767
ent separation
prkhrkat Aug 20, 2025
6e2d95d
driftSpec.yaml added
prkhrkat Aug 20, 2025
ffe67f0
fix: path params int validation updated to whole numbers only
SATYAsasini Aug 20, 2025
e695102
fix: handled resource not found response for update and delete api, t…
SATYAsasini Aug 20, 2025
bf09b2a
fix: API token generation api responses refactoring (#6788)
SATYAsasini Aug 20, 2025
f8a42bc
path corrected
prkhrkat Aug 21, 2025
6f86b87
fix: validation for SSO config name field
SATYAsasini Aug 21, 2025
40bb962
cmscs added
prkhrkat Aug 21, 2025
3ca0e87
corrected specs
prkhrkat Aug 21, 2025
0113b69
fix: enhanced query param validation for commit metadata for pipeline…
SATYAsasini Aug 21, 2025
59ea5e0
fix: disable updating clsutername and api name in update clsuter api
SATYAsasini Aug 21, 2025
eab5419
fix: enhanced api response in query param validation failure reeors i…
SATYAsasini Aug 21, 2025
62e1c62
fix: disable modifying cluster nae and env name in update env api
SATYAsasini Aug 21, 2025
e20bc6a
Merge branch 'feat-api-spec-validator' into fix-api-responses
SATYAsasini Aug 21, 2025
dd64802
fix: resolving review comments
SATYAsasini Aug 25, 2025
62ade03
fix: resolving review comments
SATYAsasini Aug 25, 2025
a8fd206
fix: enhanced api response
SATYAsasini Aug 28, 2025
d328e2a
corrected security specs
prkhrkat Aug 28, 2025
934a7bc
fix: enhanced some error messaging and missing field informations
SATYAsasini Aug 28, 2025
9d2a49b
fix: develop sync
SATYAsasini Aug 28, 2025
bcdb415
added more specs
prkhrkat Aug 29, 2025
be79d8a
fix: resolving review comment
SATYAsasini Aug 29, 2025
c017ed0
Merge pull request #6797 from devtron-labs/fix-api-responses
prkhrkat Sep 1, 2025
c37f741
added more specs
prkhrkat Sep 1, 2025
6fe67a4
helm v3 upgraded
prkhrkat Sep 2, 2025
0bee972
common-lib sync
prkhrkat Sep 2, 2025
cd3403b
Merge pull request #6809 from devtron-labs/dependa-fix
prkhrkat Sep 2, 2025
88c5a4b
Merge branch 'develop' into api-specs-post
prkhrkat Sep 4, 2025
49080ab
fix: post apis minor validations (#6811)
SATYAsasini Sep 5, 2025
e8c77be
Merge branch 'develop' into api-specs-post
prkhrkat Sep 5, 2025
ad540f4
Merge branch 'develop' into api-specs-post
prkhrkat Sep 5, 2025
2ad718a
Merge remote-tracking branch 'origin/api-specs-post' into api-specs-post
prkhrkat Sep 5, 2025
5d78006
argo-cd version fix
prkhrkat Sep 5, 2025
6c37223
Merge branch 'develop' into argo-version-update
prkhrkat Sep 5, 2025
1541f31
argo-cd version fix
prkhrkat Sep 5, 2025
dd76c1a
argo-cd version fix
prkhrkat Sep 5, 2025
7eb86d1
docker version
prkhrkat Sep 8, 2025
f9584fa
misc: Argo version update (#6817)
prkhrkat Sep 8, 2025
3e46c4e
Merge branch 'develop' into api-specs-post
prkhrkat Sep 8, 2025
5689376
sepcs
prkhrkat Sep 9, 2025
11058b3
sepcs
prkhrkat Sep 9, 2025
3a8302c
fix: get deployment history minor validations
SATYAsasini Sep 9, 2025
bdc2575
error handler correction
prkhrkat Sep 9, 2025
c388558
fix: get pre post deployment logs minor validations
SATYAsasini Sep 9, 2025
634635b
fix: get cd workflow detail and download deployment artifact param va…
SATYAsasini Sep 9, 2025
d3cac07
fix: get deployment status params error handling and messaging enhance
SATYAsasini Sep 9, 2025
c8013c1
fix: Trigger and Statuses POST api
SATYAsasini Sep 9, 2025
cf71db7
error handler correction
prkhrkat Sep 9, 2025
05118a2
eks detection
prkhrkat Sep 10, 2025
f17457f
Merge pull request #6820 from devtron-labs/fix-pk-999
prkhrkat Sep 11, 2025
2263ace
Merge branch 'develop' into api-specs-post
prkhrkat Sep 12, 2025
4ed7847
spec added git-material
prkhrkat Sep 15, 2025
99b719a
sync: sync from fix-api-post
SATYAsasini Sep 15, 2025
adeccfa
validations
prkhrkat Sep 15, 2025
7af78d0
Merge branch 'refs/heads/main' into api-specs-post
prkhrkat Sep 15, 2025
e01cbd9
validations
prkhrkat Sep 15, 2025
bb16d29
fix: api responses and specs
SATYAsasini Sep 17, 2025
b62d526
chore: resolving review comments
SATYAsasini Sep 17, 2025
1808f06
chore: resolving review comments
SATYAsasini Sep 17, 2025
46167fa
chore: resolving review comments
SATYAsasini Sep 17, 2025
4e5406d
Merge branch 'api-specs-post' into fix-api-phase-2
prkhrkat Sep 17, 2025
e7539b0
Merge pull request #6821 from devtron-labs/fix-api-phase-2
prkhrkat Sep 17, 2025
075b680
docs: deployment template api spec fixes (#6833)
SATYAsasini Sep 18, 2025
854d1c7
fix: post api fixes iteration-1 (#6835)
SATYAsasini Sep 19, 2025
883e18d
fix: app name and description validation and ephimeral container delete
SATYAsasini Sep 22, 2025
080ce13
chore: using enums despite hardcoded strings
SATYAsasini Sep 24, 2025
32fcbf4
chore: using enums despite hardcoded strings for ephimeral container …
SATYAsasini Sep 24, 2025
5630e6b
chore: removing unsed utils
SATYAsasini Sep 24, 2025
082670c
chore: removing unsed utils
SATYAsasini Sep 24, 2025
be881db
added getDeploymentTemplate spec
prkhrkat Sep 30, 2025
f568052
Merge pull request #6807 from devtron-labs/api-specs-post
prkhrkat Sep 30, 2025
afe1778
migration unique constraint on mpc
prkhrkat Oct 10, 2025
9982c7e
Merge pull request #6851 from devtron-labs/migration-sync
prkhrkat Oct 14, 2025
3525cad
main sync
Shivam-nagar23 Oct 27, 2025
6d2c166
main sync
Shivam-nagar23 Oct 27, 2025
ac9affc
Merge pull request #6855 from devtron-labs/main-sync-27-10
Shivam-nagar23 Oct 27, 2025
42623d6
sync: main sync
kartik-579 Nov 4, 2025
1ee821c
develop sync
kartik-579 Nov 4, 2025
6f2f325
Merge pull request #6857 from devtron-labs/main-sync-4nov-1
kartik-579 Nov 4, 2025
a7a7533
chore: removed redundant pvt keys and crts:
kartik-579 Nov 13, 2025
041a3e1
Merge pull request #6862 from devtron-labs/pvt-key-rm
kartik-579 Nov 13, 2025
2d2e680
compare diff fix
Shivam-nagar23 Nov 18, 2025
582185a
Merge pull request #6863 from devtron-labs/fix-compare-diff
Shivam-nagar23 Nov 18, 2025
b2309e1
removed invalid required check for ephemeral container req
kartik-579 Nov 19, 2025
7ded707
target name validation remove for ephemeral container req
kartik-579 Nov 19, 2025
25c8d82
validate correct fix
kartik-579 Nov 19, 2025
6d98343
wip
kartik-579 Nov 19, 2025
d1a6c5b
Merge branch 'release-candidate-v0.43.0' into packet-fixes-43
kartik-579 Nov 19, 2025
3fe70f9
Merge pull request #6864 from devtron-labs/packet-fixes-43
kartik-579 Nov 19, 2025
ba6fea0
make dep update oss
Shivam-nagar23 Nov 21, 2025
511d04a
main sync
Shivam-nagar23 Nov 21, 2025
ce66ccc
Merge pull request #6867 from devtron-labs/vendor-update-43
Shivam-nagar23 Nov 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions App.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package main

import (
"context"
"crypto/tls"
"errors"
"fmt"
"github.com/devtron-labs/common-lib/middlewares"
Expand Down Expand Up @@ -68,7 +67,6 @@ type App struct {
// eventProcessor.CentralEventProcessor is used to register event processors
centralEventProcessor *eventProcessor.CentralEventProcessor // do not remove this.
// used for local dev only
serveTls bool
sessionManager2 *authMiddleware.SessionManager
OtelTracingService *otel.OtelTracingServiceImpl
loggingMiddleware util.LoggingMiddleware
Expand Down Expand Up @@ -99,7 +97,6 @@ func NewApp(router *router.MuxRouter,
Enforcer: enforcer,
EnforcerV2: enforcerV2,
db: db,
serveTls: false,
sessionManager2: sessionManager2,
posthogClient: posthogClient,
OtelTracingService: otel.NewOtelTracingServiceImpl(Logger),
Expand Down Expand Up @@ -132,22 +129,7 @@ func (app *App) Start() {
app.MuxRouter.Router.Use(otelmux.Middleware(otel.OTEL_ORCHESTRASTOR_SERVICE_NAME))
}
app.server = server
var err error
if app.serveTls {
cert, err := tls.LoadX509KeyPair(
"localhost.crt",
"localhost.key",
)
if err != nil {
log.Fatal(err)
}
server.TLSConfig = &tls.Config{
Certificates: []tls.Certificate{cert},
}
err = server.ListenAndServeTLS("", "")
} else {
err = server.ListenAndServe()
}
err := server.ListenAndServe()
//err := http.ListenAndServe(fmt.Sprintf(":%d", port), auth.Authorizer(app.Enforcer, app.sessionManager)(app.MuxRouter.Router))
if err != nil && !errors.Is(err, http.ErrServerClosed) {
app.Logger.Errorw("error in startup", "err", err)
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.24.0 AS build-env
FROM golang:1.24.6 AS build-env

RUN echo $GOPATH && \
apt update && \
Expand Down
2 changes: 1 addition & 1 deletion DockerfileEA
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.24.0 AS build-env
FROM golang:1.24.6 AS build-env

RUN echo $GOPATH && \
apt update && \
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

all: fetch-all-env build

TARGET_BRANCH?=main
TARGET_BRANCH?=develop
TAG?=$(shell bash -c 'git log --pretty=format:'%h' -n 1')
FLAGS=
ENVVAR=
Expand Down
4 changes: 2 additions & 2 deletions api/appStore/chartGroup/ChartGroupRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (impl *ChartGroupRestHandlerImpl) GetChartGroupWithChartMetaData(w http.Res
}

// Use enhanced parameter parsing with context
chartGroupId, err := common.ExtractIntPathParamWithContext(w, r, "chartGroupId", "chart group")
chartGroupId, err := common.ExtractIntPathParamWithContext(w, r, "chartGroupId")
if err != nil {
// Error already written by ExtractIntPathParamWithContext
return
Expand Down Expand Up @@ -223,7 +223,7 @@ func (impl *ChartGroupRestHandlerImpl) GetChartGroupInstallationDetail(w http.Re
}

// Use enhanced parameter parsing with context
chartGroupId, err := common.ExtractIntPathParamWithContext(w, r, "chartGroupId", "chart group")
chartGroupId, err := common.ExtractIntPathParamWithContext(w, r, "chartGroupId")
if err != nil {
// Error already written by ExtractIntPathParamWithContext
return
Expand Down
6 changes: 6 additions & 0 deletions api/appStore/deployment/AppStoreDeploymentRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,10 @@ func (handler AppStoreDeploymentRestHandlerImpl) UpdateInstalledApp(w http.Respo
handler.Logger.Debugw("request payload, UpdateInstalledApp", "payload", request)
installedApp, err := handler.appStoreDeploymentDBService.GetInstalledApp(request.InstalledAppId)
if err != nil {
if util.IsErrNoRows(err) {
common.HandleResourceNotFound(w, r, "installedApp", strconv.Itoa(request.InstalledAppVersionId))
return
}
handler.Logger.Errorw("service err, UpdateInstalledApp", "err", err, "payload", request)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
return
Expand Down Expand Up @@ -461,6 +465,8 @@ func (handler AppStoreDeploymentRestHandlerImpl) UpdateInstalledApp(w http.Respo
if err != nil {
if strings.Contains(err.Error(), "application spec is invalid") {
err = &util.ApiError{Code: "400", HttpStatusCode: 400, UserMessage: "application spec is invalid, please check provided chart values"}
} else if util.IsErrNoRows(err) {
handler.Logger.Errorw("installed app not found", "err", err, "payload", request)
}
handler.Logger.Errorw("service err, UpdateInstalledApp", "err", err, "payload", request)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
Expand Down
12 changes: 7 additions & 5 deletions api/appStore/deployment/CommonDeploymentRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ func (handler *CommonDeploymentRestHandlerImpl) getAppOfferingMode(installedAppI
if len(appId) > 0 {
appIdentifier, err := handler.helmAppService.DecodeAppId(appId)
if err != nil {
err = &util.ApiError{HttpStatusCode: http.StatusBadRequest, UserMessage: "invalid app id"}
// err = &util.ApiError{HttpStatusCode: http.StatusBadRequest, UserMessage: "invalid app id"}
return appOfferingMode, installedAppDto, err
}
installedAppDto, err = handler.installedAppService.GetInstalledAppByClusterNamespaceAndName(appIdentifier)
if err != nil {
err = &util.ApiError{HttpStatusCode: http.StatusBadRequest, UserMessage: "unable to find app in database"}
// err = &util.ApiError{HttpStatusCode: http.StatusBadRequest, UserMessage: "unable to find app in database"}
return appOfferingMode, installedAppDto, err
}
// this is the case when hyperion apps does not linked yet
Expand All @@ -103,7 +103,7 @@ func (handler *CommonDeploymentRestHandlerImpl) getAppOfferingMode(installedAppI
installedAppDto.AppOfferingMode = appOfferingMode
appIdentifier, err := handler.helmAppService.DecodeAppId(appId)
if err != nil {
err = &util.ApiError{HttpStatusCode: http.StatusBadRequest, UserMessage: "invalid app id"}
// err = &util.ApiError{HttpStatusCode: http.StatusBadRequest, UserMessage: "invalid app id, expected format clusterId|namespace|releaseName"}
return appOfferingMode, installedAppDto, err
}
installedAppDto.ClusterId = appIdentifier.ClusterId
Expand All @@ -113,16 +113,17 @@ func (handler *CommonDeploymentRestHandlerImpl) getAppOfferingMode(installedAppI
} else if len(installedAppId) > 0 {
installedAppId, err := strconv.Atoi(installedAppId)
if err != nil {
err = &util.ApiError{HttpStatusCode: http.StatusBadRequest, UserMessage: "invalid installed app id"}
handler.Logger.Errorw("Invalid installedAppId expected int value", "installedAppId", installedAppId, "err", err)
return appOfferingMode, installedAppDto, err
}
installedAppDto, err = handler.installedAppService.GetInstalledAppByInstalledAppId(installedAppId)
if err != nil {
err = &util.ApiError{HttpStatusCode: http.StatusBadRequest, UserMessage: "unable to find app in database"}
// err = &util.ApiError{HttpStatusCode: http.StatusBadRequest, UserMessage: "unable to find app in database"}
return appOfferingMode, installedAppDto, err
}
} else {
err := &util.ApiError{HttpStatusCode: http.StatusBadRequest, UserMessage: "app id missing in request"}
handler.Logger.Errorw("appId is missing and is a required field", "appId", appId, "err", err)
return appOfferingMode, installedAppDto, err
}
if installedAppDto != nil && installedAppDto.InstalledAppId > 0 {
Expand Down Expand Up @@ -188,6 +189,7 @@ func (handler *CommonDeploymentRestHandlerImpl) GetDeploymentHistoryValues(w htt
v := r.URL.Query()
installedAppId := v.Get("installedAppId")
appId := v.Get("appId")

appOfferingMode, installedAppDto, err := handler.getAppOfferingMode(installedAppId, appId)
if err != nil {
common.WriteJsonResp(w, err, "bad request", http.StatusBadRequest)
Expand Down
6 changes: 3 additions & 3 deletions api/auth/user/UserRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func (handler UserRestHandlerImpl) GetById(w http.ResponseWriter, r *http.Reques
}

// Use enhanced parameter parsing with context
id, err := common.ExtractIntPathParamWithContext(w, r, "id", "user")
id, err := common.ExtractIntPathParamWithContext(w, r, "id")
if err != nil {
// Error already written by ExtractIntPathParamWithContext
return
Expand Down Expand Up @@ -334,7 +334,7 @@ func (handler UserRestHandlerImpl) DeleteUser(w http.ResponseWriter, r *http.Req
}

// Use enhanced parameter parsing with context
id, err := common.ExtractIntPathParamWithContext(w, r, "id", "user")
id, err := common.ExtractIntPathParamWithContext(w, r, "id")
if err != nil {
// Error already written by ExtractIntPathParamWithContext
return
Expand Down Expand Up @@ -427,7 +427,7 @@ func (handler UserRestHandlerImpl) BulkDeleteUsers(w http.ResponseWriter, r *htt

func (handler UserRestHandlerImpl) FetchRoleGroupById(w http.ResponseWriter, r *http.Request) {
// Use enhanced parameter parsing with context
id, err := common.ExtractIntPathParamWithContext(w, r, "id", "role group")
id, err := common.ExtractIntPathParamWithContext(w, r, "id")
if err != nil {
// Error already written by ExtractIntPathParamWithContext
return
Expand Down
2 changes: 1 addition & 1 deletion api/chartRepo/ChartRepositoryRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (handler *ChartRepositoryRestHandlerImpl) GetChartRepoById(w http.ResponseW
}

// Use enhanced parameter parsing with context
id, err := common.ExtractIntPathParamWithContext(w, r, "id", "chart repository")
id, err := common.ExtractIntPathParamWithContext(w, r, "id")
if err != nil {
// Error already written by ExtractIntPathParamWithContext
return
Expand Down
4 changes: 2 additions & 2 deletions api/cluster/ClusterRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ func (impl ClusterRestHandlerImpl) FindByIds(w http.ResponseWriter, r *http.Requ

func (impl ClusterRestHandlerImpl) FindById(w http.ResponseWriter, r *http.Request) {
// Use enhanced parameter parsing with context
clusterId, err := common.ExtractIntPathParamWithContext(w, r, "id", "cluster")
clusterId, err := common.ExtractIntPathParamWithContext(w, r, "id")
if err != nil {
// Error already written by ExtractIntPathParamWithContext
return
Expand Down Expand Up @@ -734,7 +734,7 @@ func (impl ClusterRestHandlerImpl) GetClusterNamespaces(w http.ResponseWriter, r
isActionUserSuperAdmin = true
}
// extract cluster and handle response on error
clusterId, err := common.ExtractIntPathParamWithContext(w, r, "clusterId", "cluster")
clusterId, err := common.ExtractIntPathParamWithContext(w, r, "clusterId")
if err != nil {
impl.logger.Error("error in parsing clusterId", "clusterId", clusterId, "err", err)
return
Expand Down
8 changes: 6 additions & 2 deletions api/cluster/EnvironmentRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func (impl EnvironmentRestHandlerImpl) Update(w http.ResponseWriter, r *http.Req

func (impl EnvironmentRestHandlerImpl) FindById(w http.ResponseWriter, r *http.Request) {
// Use enhanced parameter parsing with context
envId, err := common.ExtractIntPathParamWithContext(w, r, "id", "environment")
envId, err := common.ExtractIntPathParamWithContext(w, r, "id")
if err != nil {
// Error already written by ExtractIntPathParamWithContext
return
Expand Down Expand Up @@ -482,11 +482,15 @@ func (impl EnvironmentRestHandlerImpl) GetCombinedEnvironmentListForDropDownByCl
id, err := strconv.Atoi(clusterId)
if err != nil {
impl.logger.Errorw("request err, GetCombinedEnvironmentListForDropDownByClusterIds", "err", err, "clusterIdString", clusterIdString)
common.WriteJsonResp(w, err, "please send valid cluster Ids", http.StatusBadRequest)
common.HandleParameterError(w, r, "ids", clusterIdString)
return
}
clusterIds = append(clusterIds, id)
}
} else {
impl.logger.Errorw("request err empty query param, GetCombinedEnvironmentListForDropDownByClusterIds", "err", err, "clusterIdString", clusterIdString)
common.HandleParameterError(w, r, "ids", clusterIdString)
return
}
token := r.Header.Get("token")
clusters, err := impl.environmentClusterMappingsService.GetCombinedEnvironmentListForDropDownByClusterIds(token, clusterIds, impl.rbacEnforcementUtil.CheckAuthorizationForGlobalEnvironment)
Expand Down
7 changes: 7 additions & 0 deletions api/devtronResource/DevtronResourceHistoryRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,16 @@ func (handler *HistoryRestHandlerImpl) GetDeploymentHistory(w http.ResponseWrite
queryParams := apiBean.GetHistoryQueryParams{}
err := decoder.Decode(&queryParams, v)
if err != nil {
handler.logger.Errorw("error in decoding query parameters", "queryParams", v, "err", err)
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
}
// Validating that filterCriteria is provided
if len(queryParams.FilterCriteria) == 0 {
handler.logger.Errorw("missing required filterCriteria parameter")
common.HandleParameterError(w, r, "filterCriteria", "")
return
}
decodedReqBean, err := handler.apiReqDecoderService.GetFilterCriteriaParamsForDeploymentHistory(queryParams.FilterCriteria)
if err != nil {
handler.logger.Errorw("error in getting filter criteria params", "err", err, "filterCriteria", queryParams.FilterCriteria)
Expand Down
2 changes: 1 addition & 1 deletion api/helm-app/service/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
func DecodeExternalAppAppId(appId string) (*bean.AppIdentifier, error) {
component := strings.Split(appId, "|")
if len(component) != 3 {
return nil, fmt.Errorf("malformed app id %s", appId)
return nil, fmt.Errorf("malformed appId, appId: %s, expected format clusterId|namespace|releaseName", appId)
}
clusterId, err := strconv.Atoi(component[0])
if err != nil {
Expand Down
22 changes: 17 additions & 5 deletions api/k8s/application/k8sApplicationRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1002,14 +1002,19 @@
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
}
if err = handler.validator.Struct(request); err != nil || (request.BasicData == nil && request.AdvancedData == nil) {
if err != nil {
err = errors.New("invalid request payload")
}
handler.logger.Errorw("invalid request payload", "err", err, "payload", request)
if request.BasicData == nil && request.AdvancedData == nil {
err = errors.New("invalid request payload, neither basic data nor advanced data provided")
handler.logger.Errorw("invalid request payload missing basic data and invalid data", "err", err, "payload", request)
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
}
err = handler.validator.Struct(request)
if err != nil {
handler.logger.Errorw("invalid request payload", "err", err, "payload", request)

Check failure on line 1013 in api/k8s/application/k8sApplicationRestHandler.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "invalid request payload" 3 times.

See more on https://sonarcloud.io/project/issues?id=devtron-labs_devtron&issues=AZqlVivNiMvvxZiNbL0R&open=AZqlVivNiMvvxZiNbL0R&pullRequest=6866
//common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
common.HandleValidationErrors(w, r, err)
return
}
// check for super admin
restricted := handler.restrictTerminalAccessForNonSuperUsers(w, token)
if restricted {
Expand Down Expand Up @@ -1079,6 +1084,13 @@
_, err = handler.k8sApplicationService.TerminatePodEphemeralContainer(request)
if err != nil {
handler.logger.Errorw("error occurred in terminating ephemeral container", "err", err, "requestPayload", request)
if err.Error() == bean4.EXTERNAL_EPHIMERAL_CONTAINER_ERR {
common.WriteJsonResp(w, err, nil, http.StatusForbidden)
return
} else if err.Error() == bean4.EPHEMERAL_CONTAINER_NOT_FOUND_ERR {
common.WriteJsonResp(w, err, nil, http.StatusNotFound)
return
}
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
return
}
Expand Down
51 changes: 3 additions & 48 deletions api/middleware/ErrorHandlingMiddleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ package middleware
import (
"context"
"fmt"
"github.com/devtron-labs/devtron/internal/util"
"github.com/gorilla/mux"
"go.uber.org/zap"
"net/http"
"strconv"
"time"

"github.com/gorilla/mux"
"go.uber.org/zap"
)

// ErrorHandlingMiddleware provides enhanced error handling and logging for REST handlers
Expand Down Expand Up @@ -156,47 +155,3 @@ func GetRequestContext(r *http.Request) *RequestContext {
}
return nil
}

// LogError logs an error with request context for better debugging
func (m *ErrorHandlingMiddleware) LogError(r *http.Request, err error, operation string) {
reqCtx := GetRequestContext(r)
if reqCtx != nil {
m.logger.Errorw("Request error",
"requestId", reqCtx.RequestID,
"operation", operation,
"error", err,
"method", reqCtx.Method,
"path", reqCtx.Path,
"resourceType", reqCtx.ResourceType,
"resourceId", reqCtx.ResourceID,
)
} else {
m.logger.Errorw("Request error",
"operation", operation,
"error", err,
"method", r.Method,
"path", r.URL.Path,
)
}
}

// ValidateIntPathParam validates and extracts an integer path parameter with enhanced error handling
func ValidateIntPathParam(r *http.Request, paramName string) (int, *util.ApiError) {
vars := mux.Vars(r)
paramValue := vars[paramName]

if paramValue == "" {
return 0, util.NewMissingRequiredFieldError(paramName)
}

id, err := strconv.Atoi(paramValue)
if err != nil {
return 0, util.NewInvalidPathParameterError(paramName, paramValue)
}

if id <= 0 {
return 0, util.NewValidationErrorForField(paramName, "must be a positive integer")
}

return id, nil
}
Loading
Loading