Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (codex): validate hidden port fields on save

[._.]/ Adam Eivy021b975df809
diff --git a/client/src/components/apps/EditAppDrawer.jsx b/client/src/components/apps/EditAppDrawer.jsx
index 6333a2f509..b5a72206ff 100644
--- a/client/src/components/apps/EditAppDrawer.jsx
+++ b/client/src/components/apps/EditAppDrawer.jsx
@@ -32,6 +32,14 @@ const TABS = [
];
const TAB_IDS = TABS.map(t => t.id);
+// Port fields that must be validated on save even when their tab is unmounted.
+const PORT_FIELDS = [
+ ['uiPort', 'UI Port'],
+ ['devUiPort', 'Dev UI Port'],
+ ['apiPort', 'API Port'],
+ ['tlsPort', 'TLS Port']
+];
+
export default function EditAppDrawer({ app, onClose, onSave }) {
const [activeTab, setActiveTab] = useDrawerTab('appTab', 'general', TAB_IDS);
const [formData, setFormData] = useState({
@@ -167,6 +175,21 @@ export default function EditAppDrawer({ app, onClose, onSave }) {
return;
}
+ // The port inputs (type="number") live on the Ports & TLS tab and are also
+ // unmounted while another tab is active, so a bad value like `1e`/`1.5`
+ // would slip past browser validation and get silently truncated by
+ // parseInt below. Validate each provided port as a whole 1–65535 number.
+ for (const [key, label] of PORT_FIELDS) {
+ const raw = String(formData[key] ?? '').trim();
+ if (!raw) continue;
+ const port = Number(raw);
+ if (!/^\d+$/.test(raw) || port < 1 || port > 65535) {
+ setActiveTab('ports');
+ setError(`${label} must be a whole number between 1 and 65535.`);
+ return;
+ }
+ }
+
setSaving(true);
const data = {
diff --git a/client/src/components/apps/EditAppDrawer.test.jsx b/client/src/components/apps/EditAppDrawer.test.jsx
index c59937a171..49912602dd 100644
--- a/client/src/components/apps/EditAppDrawer.test.jsx
+++ b/client/src/components/apps/EditAppDrawer.test.jsx
@@ -145,4 +145,19 @@ describe('EditAppDrawer required-field validation across tabs', () => {
);
expect(api.updateApp).not.toHaveBeenCalled();
});
+
+ it('blocks Save when a hidden port field holds a non-integer value', async () => {
+ renderDrawer({ app: { ...APP, uiPort: '1.5' } });
+ // Leave the Ports tab and try to save; the unmounted number input can't
+ // self-validate, so handleSubmit must catch it and surface the Ports tab.
+ await openTab('Workflow');
+
+ fireEvent.click(screen.getByRole('button', { name: 'Save Changes' }));
+
+ await waitFor(() =>
+ expect(screen.getByText('UI Port must be a whole number between 1 and 65535.')).toBeInTheDocument()
+ );
+ expect(api.updateApp).not.toHaveBeenCalled();
+ expect(await screen.findByLabelText('UI Port')).toBeInTheDocument();
+ });
});