Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

fix(dribbble): map 4xx shot rejections to non-retryable BadBody

Gilad Resisia63b28bf371d
diff --git a/libraries/nestjs-libraries/src/integrations/social/dribbble.provider.ts b/libraries/nestjs-libraries/src/integrations/social/dribbble.provider.ts
index 08f26e093..dc325e09b 100644
--- a/libraries/nestjs-libraries/src/integrations/social/dribbble.provider.ts
+++ b/libraries/nestjs-libraries/src/integrations/social/dribbble.provider.ts
@@ -8,6 +8,7 @@ import {
import { makeSecureId } from '@gitroom/nestjs-libraries/services/make.secure.id';
import FormData from 'form-data';
import {
+ BadBody,
SocialAbstract,
ValidityMedia,
} from '@gitroom/nestjs-libraries/integrations/social.abstract';
@@ -180,16 +181,31 @@ export class DribbbleProvider extends SocialAbstract implements SocialProvider {
formData.append('title', postDetails[0].settings.title);
formData.append('description', postDetails[0].message);
- const data2 = await this.getSsrfSafeAxios().post(
- 'https://api.dribbble.com/v2/shots',
- formData,
- {
- headers: {
- ...formData.getHeaders(),
- Authorization: `Bearer ${accessToken}`,
- },
+ let data2;
+ try {
+ data2 = await this.getSsrfSafeAxios().post(
+ 'https://api.dribbble.com/v2/shots',
+ formData,
+ {
+ headers: {
+ ...formData.getHeaders(),
+ Authorization: `Bearer ${accessToken}`,
+ },
+ }
+ );
+ } catch (err: any) {
+ const status = err?.response?.status;
+ if (status >= 400 && status < 500 && status !== 429) {
+ throw new BadBody(
+ this.identifier,
+ JSON.stringify(err?.response?.data ?? {}),
+ '{}',
+ err?.response?.data?.message ||
+ `Dribbble rejected the shot with status ${status}`
+ );
}
- );
+ throw err;
+ }
const location = data2.headers['location'];
const newId = location.split('/').at(-1);