Skip to content

Commit

Permalink
enhance: use constant for complexity limit
Browse files Browse the repository at this point in the history
  • Loading branch information
plyr4 committed Oct 30, 2023
1 parent f2ec456 commit e7b5e8d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions api/build/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ type stg struct {

const (
// clusters determine graph orientation
BuiltInCluster = 2
PipelineCluster = 1
ServiceCluster = 0
BuiltInCluster = 2
PipelineCluster = 1
ServiceCluster = 0
GraphComplexityLimit = 1000
)

// swagger:operation GET /api/v1/repos/{org}/{repo}/builds/{build}/graph builds GetBuildGraph
Expand Down Expand Up @@ -496,10 +497,8 @@ func GetBuildGraph(c *gin.Context) {
}
}

// for loop over edges, and collapse same parent edge
// todo: move this check above the processing ?
if len(nodes) > 5000 {
c.JSON(http.StatusInternalServerError, "too many nodes on this graph")
if len(nodes) > GraphComplexityLimit || len(nodes) > GraphComplexityLimit {
c.JSON(http.StatusInternalServerError, "too many nodes or edges on this graph")
return
}

Expand Down

0 comments on commit e7b5e8d

Please sign in to comment.