[PR #819] [MERGED] Fix Submit Dialog Button Behavior with 500 Errors on Duplicate Names #794

Closed
opened 2025-10-31 15:22:01 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/moghtech/komodo/pull/819
Author: @MP-Tool
Created: 9/6/2025
Status: Merged
Merged: 9/7/2025
Merged by: @mbecker20

Base: 1.19.4Head: fix/submit-dialog-button-behavior


📝 Commits (5)

  • 00388b9 Implement enhanced error handling and messaging for resource creation
  • 2e67778 Implement improved error handling for resource creation across alerter, build, and sync
  • 40ff9ae Implement error handling improvements for resource copying and validation feedback
  • ec81518 Adjust error handling for resource creation to distinguish validation errors from unexpected system errors
  • 0f36679 Refactor resource creation error handling by removing redundant match statements and simplifying the error propagation in multiple API modules.

📊 Changes

15 files changed (+62 additions, -104 deletions)

View changed files

📝 bin/core/src/api/write/action.rs (+2 -8)
📝 bin/core/src/api/write/alerter.rs (+2 -8)
📝 bin/core/src/api/write/build.rs (+2 -8)
📝 bin/core/src/api/write/builder.rs (+2 -8)
📝 bin/core/src/api/write/deployment.rs (+3 -12)
📝 bin/core/src/api/write/procedure.rs (+2 -8)
📝 bin/core/src/api/write/repo.rs (+2 -5)
📝 bin/core/src/api/write/server.rs (+3 -8)
📝 bin/core/src/api/write/stack.rs (+3 -8)
📝 bin/core/src/api/write/sync.rs (+2 -12)
📝 bin/core/src/resource/mod.rs (+7 -5)
📝 bin/core/src/sync/execute.rs (+1 -0)
📝 bin/core/src/sync/resources.rs (+1 -0)
📝 frontend/src/components/layouts.tsx (+5 -2)
📝 frontend/src/components/resources/common.tsx (+25 -12)

📄 Description

Overview

Resolves issue #771 by implementing proper HTTP status codes and improving error handling for resource creation/copying operations.

Problem

Previously, duplicate name errors returned HTTP 500 (Internal Server Error) instead of appropriate status codes, causing:

  • Submit dialogs to close immediately on validation errors
  • Poor user experience requiring data re-entry
  • Inconsistent error handling across the application
  • Console errors instead of appropriate warnings for expected user errors

Solution

Backend Changes

  • Centralized error handling: Added handle_resource_creation_error() function in bin/core/src/api/write/mod.rs
  • Proper HTTP status codes:
    • 409 Conflict for duplicate names and busy resources
    • 400 Bad Request for validation errors (empty names, invalid ObjectIds, permission errors)
    • 500 Internal Server Error only for actual system errors
  • Consistent implementation: Applied to all resource types (Stack, Server, Action, Repo, Build, Alerter, ResourceSync)
  • Enhanced error messages: "Resource with name '{}' already exists" for better clarity

Frontend Changes

  • Status-code-based error detection: Replaced message-based error parsing with HTTP status code classification
  • Improved dialog behavior:
    • Create/Copy dialogs remain open on validation errors (409/400)
    • Dialogs close only on successful operations or system errors (500+)
  • Enhanced logging strategy:
    • Validation errors logged as warnings (expected user behavior)
    • System errors logged as errors (unexpected failures)
  • User-friendly error messages: Clear, actionable feedback for validation errors

Impact

  • Better UX: Users no longer need to re-enter data when fixing validation errors
  • Proper HTTP semantics: Status codes now correctly reflect the type of error
  • Improved debugging: Clear distinction between validation issues and system failures
  • Consistent error handling: Unified approach across all resource creation/copying operations

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/moghtech/komodo/pull/819 **Author:** [@MP-Tool](https://github.com/MP-Tool) **Created:** 9/6/2025 **Status:** ✅ Merged **Merged:** 9/7/2025 **Merged by:** [@mbecker20](https://github.com/mbecker20) **Base:** `1.19.4` ← **Head:** `fix/submit-dialog-button-behavior` --- ### 📝 Commits (5) - [`00388b9`](https://github.com/moghtech/komodo/commit/00388b9a30e6b94a38bff8149385c0a7dc7e1f69) Implement enhanced error handling and messaging for resource creation - [`2e67778`](https://github.com/moghtech/komodo/commit/2e67778663f33c7ab52544179989ef6462f34f81) Implement improved error handling for resource creation across alerter, build, and sync - [`40ff9ae`](https://github.com/moghtech/komodo/commit/40ff9ae6a275828a99c5ed79f15934171422405b) Implement error handling improvements for resource copying and validation feedback - [`ec81518`](https://github.com/moghtech/komodo/commit/ec815186cb57ec1f996d2a38be76dd0571f46c62) Adjust error handling for resource creation to distinguish validation errors from unexpected system errors - [`0f36679`](https://github.com/moghtech/komodo/commit/0f3667910d30e2d1731b6b0f55670570e9a95637) Refactor resource creation error handling by removing redundant match statements and simplifying the error propagation in multiple API modules. ### 📊 Changes **15 files changed** (+62 additions, -104 deletions) <details> <summary>View changed files</summary> 📝 `bin/core/src/api/write/action.rs` (+2 -8) 📝 `bin/core/src/api/write/alerter.rs` (+2 -8) 📝 `bin/core/src/api/write/build.rs` (+2 -8) 📝 `bin/core/src/api/write/builder.rs` (+2 -8) 📝 `bin/core/src/api/write/deployment.rs` (+3 -12) 📝 `bin/core/src/api/write/procedure.rs` (+2 -8) 📝 `bin/core/src/api/write/repo.rs` (+2 -5) 📝 `bin/core/src/api/write/server.rs` (+3 -8) 📝 `bin/core/src/api/write/stack.rs` (+3 -8) 📝 `bin/core/src/api/write/sync.rs` (+2 -12) 📝 `bin/core/src/resource/mod.rs` (+7 -5) 📝 `bin/core/src/sync/execute.rs` (+1 -0) 📝 `bin/core/src/sync/resources.rs` (+1 -0) 📝 `frontend/src/components/layouts.tsx` (+5 -2) 📝 `frontend/src/components/resources/common.tsx` (+25 -12) </details> ### 📄 Description ## Overview Resolves issue #771 by implementing proper HTTP status codes and improving error handling for resource creation/copying operations. ## Problem Previously, duplicate name errors returned HTTP 500 (Internal Server Error) instead of appropriate status codes, causing: - Submit dialogs to close immediately on validation errors - Poor user experience requiring data re-entry - Inconsistent error handling across the application - Console errors instead of appropriate warnings for expected user errors ## Solution ### Backend Changes - **Centralized error handling**: Added `handle_resource_creation_error()` function in `bin/core/src/api/write/mod.rs` - **Proper HTTP status codes**: - `409 Conflict` for duplicate names and busy resources - `400 Bad Request` for validation errors (empty names, invalid ObjectIds, permission errors) - `500 Internal Server Error` only for actual system errors - **Consistent implementation**: Applied to all resource types (Stack, Server, Action, Repo, Build, Alerter, ResourceSync) - **Enhanced error messages**: "Resource with name '{}' already exists" for better clarity ### Frontend Changes - **Status-code-based error detection**: Replaced message-based error parsing with HTTP status code classification - **Improved dialog behavior**: - Create/Copy dialogs remain open on validation errors (409/400) - Dialogs close only on successful operations or system errors (500+) - **Enhanced logging strategy**: - Validation errors logged as warnings (expected user behavior) - System errors logged as errors (unexpected failures) - **User-friendly error messages**: Clear, actionable feedback for validation errors ## Impact - **Better UX**: Users no longer need to re-enter data when fixing validation errors - **Proper HTTP semantics**: Status codes now correctly reflect the type of error - **Improved debugging**: Clear distinction between validation issues and system failures - **Consistent error handling**: Unified approach across all resource creation/copying operations --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-10-31 15:22:01 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/komodo#794