π¨ The ultimate agentic social media scheduling tool π€
TypeScript nextjsopen-sourceopen-source-social-media-scheduling-toolosspostiz-cloudpostiz-hostedredisscheduling-toolsocial-media-scheduling-tooltypescript
fix(calendar): surface curated provider errors in the calendar tooltip
Gilad Resisi291b07b4b7c7
diff --git a/apps/frontend/src/components/launches/calendar.tsx b/apps/frontend/src/components/launches/calendar.tsxindex 0f3ae954d..fe01e2b85 100644--- a/apps/frontend/src/components/launches/calendar.tsx+++ b/apps/frontend/src/components/launches/calendar.tsx@@ -59,6 +59,21 @@ import { stripHtmlValidation } from '@gitroom/helpers/utils/strip.html.validatioimport { newDayjs } from '@gitroom/frontend/components/layout/set.timezone';import { Button } from '@gitroom/react/form/button';+// Curated provider errors are stored as {"message":"..."} β anything else in+// post.error (internal strings like 'Refresh channel needed', serialized+// failures from before curation existed) falls back to the generic tooltip+const displayErrorMessage = (error?: string | null) => {+ if (!error) {+ return null;+ }+ try {+ const parsed = JSON.parse(error);+ return typeof parsed?.message === 'string' ? parsed.message : null;+ } catch (e) {+ return null;+ }+};+// Extend dayjs with necessary pluginsextend(isSameOrAfter);extend(isSameOrBefore);@@ -1059,7 +1074,8 @@ const CalendarItem: FC<{<divclassName="absolute -top-[6px] -left-[6px] z-20 w-[18px] h-[18px] rounded-full bg-red-500 flex items-center justify-center text-white text-[11px] font-bold cursor-pointer"data-tooltip-id="tooltip"- data-tooltip-content={post.error || 'An error occurred while publishing this post'}+ data-tooltip-class-name="!max-w-[400px] break-words"+ data-tooltip-content={displayErrorMessage(post.error) || 'An error occurred while publishing this post'}>!</div>diff --git a/libraries/nestjs-libraries/src/database/prisma/posts/posts.repository.ts b/libraries/nestjs-libraries/src/database/prisma/posts/posts.repository.tsindex 1aa9e1538..38ed9bc83 100644--- a/libraries/nestjs-libraries/src/database/prisma/posts/posts.repository.ts+++ b/libraries/nestjs-libraries/src/database/prisma/posts/posts.repository.ts@@ -172,6 +172,7 @@ export class PostsRepository {releaseURL: true,releaseId: true,state: true,+ error: true,intervalInDays: true,group: true,creationMethod: true,@@ -411,15 +412,34 @@ export class PostsRepository {}async changeState(id: string, state: State, err?: any, body?: any) {+ // The calendar tooltip only surfaces curated provider messages: bad_body+ // failures whose message came from a handleErrors mapping or a+ // hand-written provider throw (unmapped API responses carry the+ // 'Unknown Error' placeholder instead). Those are stored as+ // {"message":"..."} so the frontend can tell them apart from everything+ // this column held until now (internal strings like 'Refresh channel+ // needed', serialized failures), which keeps rendering the generic+ // tooltip. Internal strings are still stored for debugging, and the full+ // failure is kept in the Errors table below.+ const failureMessage =+ err?.cause?.failure?.message || err?.failure?.cause?.message;+ const errorMessage = !err+ ? undefined+ : typeof err === 'string'+ ? err // stored for debugging, rendered as the generic tooltip+ : err?.cause?.type === 'bad_body' &&+ failureMessage &&+ failureMessage !== 'Unknown Error'+ ? JSON.stringify({ message: failureMessage })+ : undefined;+const update = await this._post.model.post.update({where: {id,},data: {state,- ...(err- ? { error: typeof err === 'string' ? err : JSON.stringify(err) }- : {}),+ ...(errorMessage ? { error: errorMessage } : {}),},include: {integration: {diff --git a/libraries/nestjs-libraries/src/integrations/social.abstract.ts b/libraries/nestjs-libraries/src/integrations/social.abstract.tsindex 93c1ec2ce..af74d345f 100644--- a/libraries/nestjs-libraries/src/integrations/social.abstract.ts+++ b/libraries/nestjs-libraries/src/integrations/social.abstract.ts@@ -183,11 +183,13 @@ export abstract class SocialAbstract {pendingData: any,integration: Integration): Promise<PendingCheckResponse> {+ // 'Unknown Error' keeps this developer guard out of the user-facing+ // post.error (changeState only surfaces curated bad_body messages)throw new BadBody(this.identifier,+ '{"error":"checkPostStatus is not implemented for this provider"}','{}',- '{}',- 'checkPostStatus is not implemented for this provider'+ 'Unknown Error');}@@ -199,9 +201,9 @@ export abstract class SocialAbstract {): Promise<PendingCheckResponse> {throw new BadBody(this.identifier,+ '{"error":"finalizePost is not implemented for this provider"}','{}',- '{}',- 'finalizePost is not implemented for this provider'+ 'Unknown Error');}