Skip to content

The open alternative to Salesforce, designed for AI.

fix: autogrow input sizing + surface nested error details in upgrade command (#18796)

Charles Bochet66be7c3ef4fa
diff --git a/packages/twenty-front/src/modules/ui/input/components/TextInput.tsx b/packages/twenty-front/src/modules/ui/input/components/TextInput.tsx
index 77b67d8f39a..c0525fe7820 100644
--- a/packages/twenty-front/src/modules/ui/input/components/TextInput.tsx
+++ b/packages/twenty-front/src/modules/ui/input/components/TextInput.tsx
@@ -1,4 +1,5 @@
import { InputErrorHelper } from '@/ui/input/components/InputErrorHelper';
+import { isNonEmptyString } from '@sniptt/guards';
import { isDefined } from 'twenty-shared/utils';
import { InputLabel } from '@/ui/input/components/InputLabel';
import { css } from '@linaria/core';
@@ -459,7 +460,7 @@ const TextInputWithAutoGrowWrapper = forwardRef<
{props.autoGrow ? (
<StyledAutogrowWrapper
sizeVariant={props.sizeVariant}
- node={props.value ?? props.placeholder}
+ node={isNonEmptyString(props.value) ? props.value : props.placeholder}
>
<TextInputComponent
// oxlint-disable-next-line react/jsx-props-no-spreading
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/1-19/1-19-add-missing-system-fields-to-standard-objects.command.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/1-19/1-19-add-missing-system-fields-to-standard-objects.command.ts
index 3a9a89504f8..f9c2533b1ba 100644
--- a/packages/twenty-server/src/database/commands/upgrade-version-command/1-19/1-19-add-missing-system-fields-to-standard-objects.command.ts
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/1-19/1-19-add-missing-system-fields-to-standard-objects.command.ts
@@ -55,27 +55,56 @@ const FIRST_NON_TS_VECTOR_UNIVERSAL_IDENTIFIER =
const DUPLICATE_KEY_MESSAGE = 'duplicate key value violates unique constraint';
+const getNestedErrorMessages = (
+ error: WorkspaceMigrationRunnerException,
+): string | undefined => {
+ const nestedErrors = error.errors;
+
+ if (!isDefined(nestedErrors)) {
+ return undefined;
+ }
+
+ const details = [
+ nestedErrors.metadata && `metadata: ${nestedErrors.metadata.message}`,
+ nestedErrors.workspaceSchema &&
+ `workspaceSchema: ${nestedErrors.workspaceSchema.message}`,
+ nestedErrors.actionTranspilation &&
+ `actionTranspilation: ${nestedErrors.actionTranspilation.message}`,
+ ]
+ .filter(isDefined)
+ .join('; ');
+
+ return details || undefined;
+};
+
const isUniqueViolationError = (error: Error): boolean => {
if (error.message.includes(DUPLICATE_KEY_MESSAGE)) {
return true;
}
if (error instanceof WorkspaceMigrationRunnerException) {
- const nestedErrors = [
- error.errors?.metadata,
- error.errors?.workspaceSchema,
- error.errors?.actionTranspilation,
- ];
-
- return nestedErrors.some(
- (nestedError) =>
- nestedError?.message?.includes(DUPLICATE_KEY_MESSAGE) === true,
- );
+ const nestedMessages = getNestedErrorMessages(error);
+
+ return nestedMessages?.includes(DUPLICATE_KEY_MESSAGE) === true;
}
return false;
};
+const enrichErrorMessage = (error: Error): Error => {
+ if (!(error instanceof WorkspaceMigrationRunnerException)) {
+ return error;
+ }
+
+ const details = getNestedErrorMessages(error);
+
+ if (isDefined(details)) {
+ error.message = `${error.message} (${details})`;
+ }
+
+ return error;
+};
+
@Command({
name: 'upgrade:1-19:add-missing-system-fields-to-standard-objects',
description:
@@ -123,7 +152,7 @@ export class AddMissingSystemFieldsToStandardObjectsCommand extends ActiveOrSusp
});
} catch (error) {
if (!isUniqueViolationError(error)) {
- throw error;
+ throw enrichErrorMessage(error);
}
this.logger.warn(
@@ -182,7 +211,7 @@ export class AddMissingSystemFieldsToStandardObjectsCommand extends ActiveOrSusp
});
} catch (error) {
if (!isUniqueViolationError(error)) {
- throw error;
+ throw enrichErrorMessage(error);
}
this.logger.warn(