From e63cd50954fb582620a4e5f4c8133a6e42e71169 Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Wed, 23 Apr 2025 23:42:09 -0400 Subject: [PATCH] Fix error handling in SwaggerJSONHandler to ensure working directory retrieval is validated --- internal/api/handlers/v0/swagger.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/api/handlers/v0/swagger.go b/internal/api/handlers/v0/swagger.go index f7cdcd5..fea5b29 100644 --- a/internal/api/handlers/v0/swagger.go +++ b/internal/api/handlers/v0/swagger.go @@ -34,7 +34,11 @@ func SwaggerHandler() http.HandlerFunc { func SwaggerJSONHandler() http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { // Find the project root directory - workDir, _ := os.Getwd() + workDir, err := os.Getwd() + if err != nil { + http.Error(w, "Unable to determine working directory", http.StatusInternalServerError) + return + } // Path to the swagger YAML file swaggerFilePath := filepath.Join(workDir, "internal", "docs", "swagger.yaml")