Fix error handling in SwaggerJSONHandler to ensure working directory retrieval is validated

This commit is contained in:
Avinash Sridhar 2025-04-23 23:42:09 -04:00
commit e63cd50954
No known key found for this signature in database

View file

@ -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")