Skip to content

fix(ui): Send credentials for existing database deployments#56

Merged
nfebe merged 2 commits intomainfrom
fix/existing-db-credentials
Mar 29, 2026
Merged

fix(ui): Send credentials for existing database deployments#56
nfebe merged 2 commits intomainfrom
fix/existing-db-credentials

Conversation

@nfebe
Copy link
Copy Markdown
Contributor

@nfebe nfebe commented Mar 29, 2026

When using an existing database, the modal now sends a databases array entry with user-provided credentials instead of only the container name. Also fixes preview defaults to match backend naming convention ({name}_primary_db / {name}_primary_user) and adds password preview. Multi-database entries now include password for existing/external modes.

When using an existing database, the modal now sends a databases array
entry with user-provided credentials instead of only the container
name. Also fixes preview defaults to match backend naming convention
({name}_primary_db / {name}_primary_user) and adds password preview.
Multi-database entries now include password for existing/external modes.

Signed-off-by: nfebe <fenn25.fn@gmail.com>
@sourceant
Copy link
Copy Markdown

sourceant bot commented Mar 29, 2026

Code Review Summary

This PR fixes a bug where credentials were not sent when using an existing database. It also improves UI feedback by showing required markers and a password preview mask.

🚀 Key Improvements

  • Credentials (user, db, password) are now included in the payload for existing database deployments.
  • Centralized database-to-payload mapping logic via mapDbToPayload.
  • Added validation requirements for existing database configuration to prevent incomplete deployments.

💡 Minor Suggestions

  • Safe integer parsing for ports to avoid NaN in JSON.
  • Simplified password conditional in the mapper.

Copy link
Copy Markdown

@sourceant sourceant bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review complete. No specific code suggestions were generated. See the overview comment for a summary.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 29, 2026

Deploying flatrun-ui with  Cloudflare Pages  Cloudflare Pages

Latest commit: ba3451e
Status: ✅  Deploy successful!
Preview URL: https://371721d1.flatrun-ui.pages.dev
Branch Preview URL: https://fix-existing-db-credentials.flatrun-ui.pages.dev

View logs

@nfebe nfebe force-pushed the fix/existing-db-credentials branch from 3050eed to 35f7607 Compare March 29, 2026 16:58
Copy link
Copy Markdown

@sourceant sourceant bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review complete. See the overview comment for a summary.

service: db.service || undefined,
existing_container: db.mode === "existing" ? db.existingContainer : undefined,
external_host: db.mode === "external" ? db.externalHost : undefined,
external_port:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the mode is 'existing', the externalPort might be provided as a string depending on input handling. However, 'existing' database connections typically rely on internal network naming or the existing_container field rather than an external port. If the backend specifically requires a port for existing containers, ensure it defaults safely.

Suggested change
external_port:
external_port:
(db.mode === "existing" || db.mode === "external") && db.externalPort
? parseInt(db.externalPort.toString())
: undefined,

service: "",
existingContainer: form.database.existingContainer,
externalHost: "",
externalPort: form.database.externalPort,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing form.database.externalPort to the mapper when mode is 'existing' might be unnecessary or confusing if that field isn't visible/relevant for existing container connections in the UI. Consider if this should be explicitly set or if the UI ensures it's cleared.

Suggested change
externalPort: form.database.externalPort,
externalPort: form.database.mode === "external" ? form.database.externalPort : "",

Database name, username, and password are now required fields when
using an existing database. Step validation blocks progress until
all three are filled. Preview shows actual values instead of
generated defaults.

Signed-off-by: nfebe <fenn25.fn@gmail.com>
@nfebe nfebe force-pushed the fix/existing-db-credentials branch from 35f7607 to ba3451e Compare March 29, 2026 17:01
Copy link
Copy Markdown

@sourceant sourceant bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review complete. See the overview comment for a summary.

(db.mode === "existing" || db.mode === "external") && db.externalPort ? parseInt(db.externalPort) : undefined,
database_name: db.dbName || undefined,
username: db.dbUser || undefined,
password: db.mode === "existing" || db.mode === "external" ? db.dbPassword || undefined : undefined,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mapping logic should also include db.dbPassword for the 'create' mode if the backend requires it, or ensure it is consistently handled. Currently, it only sends password for 'existing' or 'external'. If 'create' generates a password on the backend, this is fine, but if the user provides it during 'create', it will be dropped.

Suggested change
password: db.mode === "existing" || db.mode === "external" ? db.dbPassword || undefined : undefined,
password: db.dbPassword || undefined,

@nfebe nfebe merged commit 1e3737b into main Mar 29, 2026
5 checks passed
@nfebe nfebe deleted the fix/existing-db-credentials branch March 29, 2026 20:06
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.

1 participant