Skip to content

feat(client): prevent error toaster when submitting edited engine det…#1808

Merged
anurag91jain merged 1 commit intodevfrom
1799-error-toaster-displayed-when-submitting-edited-model
Sep 2, 2025
Merged

feat(client): prevent error toaster when submitting edited engine det…#1808
anurag91jain merged 1 commit intodevfrom
1799-error-toaster-displayed-when-submitting-edited-model

Conversation

@AJMADHAB
Copy link
Copy Markdown
Contributor

@AJMADHAB AJMADHAB commented Sep 2, 2025

…ails

Description

prevent error toaster when submitting edited engine details with all mandatory fields filled.

Changes Made

  1. Modified EngineHeader.tsx
  2. Modified EngineLayout.tsx
  3. Modified EngineContext.tsx

How to Test

  1. Steps to reproduce/test the behavior
  2. Expected outcomes

Notes

@AJMADHAB AJMADHAB self-assigned this Sep 2, 2025
@AJMADHAB AJMADHAB requested a review from a team as a code owner September 2, 2025 13:36
@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 2, 2025

@CodiumAI-Agent /describe

@QodoAI-Agent
Copy link
Copy Markdown

Title

feat(client): prevent error toaster when submitting edited engine det…


User description

…ails

Description

prevent error toaster when submitting edited engine details with all mandatory fields filled.

Changes Made

  1. Modified EngineHeader.tsx
  2. Modified EngineLayout.tsx
  3. Modified EngineContext.tsx

How to Test

  1. Steps to reproduce/test the behavior
  2. Expected outcomes

Notes


PR Type

Bug fix, Enhancement


Description

  • Move database_subtype out of metadata

  • Fix export button engine type lookup

  • Extend EngineContext with database_subtype


Diagram Walkthrough

flowchart LR
  EngineLayout["EngineLayout: set active fields"] -- "promote database_subtype" --> EngineContext["EngineContext: add database_subtype field"]
  EngineHeader["EngineHeader: export click handler"] -- "read active.database_subtype" --> ExportFlow["Correct export logic"]
Loading

File Walkthrough

Relevant files
Bug fix
EngineHeader.tsx
Use top-level database_subtype in header                                 

packages/client/src/components/engine/EngineHeader.tsx

  • Read engine type from active.database_subtype
  • Avoid accessing metadata.database_subtype
+1/-1     
Enhancement
EngineContext.tsx
Extend context with database_subtype                                         

packages/client/src/contexts/EngineContext.tsx

  • Add optional database_subtype to context type
  • Document field as part of active engine
+1/-0     
EngineLayout.tsx
Promote database_subtype out of metadata                                 

packages/client/src/pages/engine/EngineLayout.tsx

  • Stop nesting database_subtype in metadata
  • Provide database_subtype as top-level active field
+2/-5     

@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 2, 2025

@CodiumAI-Agent /review

@QodoAI-Agent
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Possible Issue

active.database_subtype is now accessed directly; ensure active always includes this field to avoid undefined checks failing or runtime errors in environments where context may not yet be populated.

const engineType =
	active.database_subtype;
if (engineType === "H2_DB") {
	setOpenExportModal(true);
Backward Compatibility

database_subtype moved out of metadata into a top-level field; verify all consumers are updated to stop reading metadata.database_subtype and handle the optional nature of the new field.

	metadata: values,
	database_subtype: getEngineMetadata.data?.database_subtype,
	refresh: getEngineMetadata.refresh,
},

@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 2, 2025

@CodiumAI-Agent /improve

@QodoAI-Agent
Copy link
Copy Markdown

PR Code Suggestions ✨

CategorySuggestion                                                                                                                                    Impact
Possible issue
Handle undefined database subtype

Guard against active.database_subtype being undefined to prevent runtime errors and
unintended branch execution. Provide a safe default or short-circuit to avoid
calling exportDB when the subtype is unknown.

packages/client/src/components/engine/EngineHeader.tsx [158-163]

-const engineType =
-	active.database_subtype;
+const engineType = active.database_subtype ?? "";
 if (engineType === "H2_DB") {
 	setOpenExportModal(true);
-} else {
+} else if (engineType) {
 	exportDB(false);
+}
Suggestion importance[1-10]: 6

__

Why: The guard against an undefined active.database_subtype is reasonable given it became optional in context and prevents unintended exportDB calls; however, it's a minor defensive fix and may alter behavior if previously relying on falsy values.

Low
General
Normalize subtype to string

Ensure database_subtype is a string when present to align with its usage in strict
equality checks. Coerce to empty string if nullish to avoid passing undefined
through context consumers.

packages/client/src/pages/engine/EngineLayout.tsx [214-223]

 active: {
 	id: engineId,
 	role: getUserEnginePermission.data.permission,
 	name: removeUnderscores(
 		(getEngineMetadata.data?.database_name as string) || "",
 	),
 	metadata: values,
-	database_subtype: getEngineMetadata.data?.database_subtype,
+	database_subtype: getEngineMetadata.data?.database_subtype ?? "",
 	refresh: getEngineMetadata.refresh,
 },
Suggestion importance[1-10]: 5

__

Why: Normalizing database_subtype to a string can simplify consumers doing strict comparisons, but the context type declares it optional; forcing "" may conflate “unknown” with an empty subtype and subtly change semantics, making impact moderate.

Low

@anurag91jain anurag91jain merged commit f8495ee into dev Sep 2, 2025
4 checks passed
@anurag91jain anurag91jain deleted the 1799-error-toaster-displayed-when-submitting-edited-model branch September 2, 2025 16:02
@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 2, 2025

@CodiumAI-Agent /update_changelog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error toaster displayed when submitting edited model with all mandatory fields filled

3 participants