From fa09c982c8b2f5cdb76c85f00bd19ad4bcd5e39b Mon Sep 17 00:00:00 2001 From: Samuel Bodin <1637651+bodinsamuel@users.noreply.github.com> Date: Thu, 30 Jan 2025 10:18:45 +0100 Subject: [PATCH 1/3] fix: eslint pass --- eslint.config.mjs | 6 ++--- .../model.service.unit.test.ts.snap | 5 ----- packages/cli/lib/services/dryrun.service.ts | 22 +++++++++---------- packages/cli/lib/services/sdk.ts | 11 +++++----- packages/connect-ui/src/lib/api.ts | 1 - ...155149_migrate_external_webhooks_table.cjs | 1 - packages/persist/lib/tracer.ts | 2 +- packages/runner-sdk/models.d.ts | 5 ----- packages/runner/lib/idle.ts | 2 +- packages/runner/lib/register.ts | 2 +- .../lib/workers/cleanup/cleanup.worker.ts | 2 +- .../lib/workers/monitor/monitor.worker.ts | 2 +- .../workers/scheduling/scheduling.worker.ts | 2 +- .../connect/sessions/postConnectSessions.ts | 2 +- packages/server/lib/refreshConnections.ts | 2 +- .../lib/webhook/checkr-webhook-routing.ts | 4 ++++ .../hubspot-webhook-routing.unit.test.ts | 4 ++-- packages/server/lib/webhook/internal-nango.ts | 2 +- .../lib/webhook/linear-webhook-routing.ts | 4 ++++ packages/server/lib/webhook/types.ts | 2 +- packages/shared/lib/utils/error.ts | 6 ++--- packages/types/lib/runner/sdk.ts | 4 ---- .../webapp/src/pages/Environment/Settings.tsx | 2 +- .../webapp/src/pages/GettingStarted/Show.tsx | 2 +- packages/webhooks/lib/auth.unit.test.ts | 1 - packages/webhooks/lib/forward.unit.test.ts | 1 - .../webhook-settings-migration/migrate.ts | 1 - scripts/runner-update-env.js | 1 - 28 files changed, 45 insertions(+), 56 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index d1bd6e5289f..d3637c1cc17 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -108,8 +108,6 @@ export default tseslint.config( 'no-unused-vars': 'off', '@typescript-eslint/no-inferrable-types': 'off', '@typescript-eslint/require-await': 'error', - '@typescript-eslint/no-non-null-assertion': 'warn', - '@typescript-eslint/no-explicit-any': 'warn', '@typescript-eslint/restrict-template-expressions': [ 'error', @@ -122,7 +120,7 @@ export default tseslint.config( '@typescript-eslint/await-thenable': 'error', '@typescript-eslint/no-invalid-void-type': 'warn', - '@typescript-eslint/no-base-to-string': 'warn', + '@typescript-eslint/no-base-to-string': 'error', '@typescript-eslint/restrict-plus-operands': 'warn', '@typescript-eslint/consistent-type-exports': 'error', '@typescript-eslint/no-unnecessary-condition': 'off', @@ -161,6 +159,8 @@ export default tseslint.config( '@typescript-eslint/no-deprecated': 'warn', '@typescript-eslint/no-floating-promises': 'warn', '@typescript-eslint/no-unsafe-assignment': 'warn', + '@typescript-eslint/no-non-null-assertion': 'warn', + '@typescript-eslint/no-explicit-any': 'warn', '@typescript-eslint/no-unsafe-member-access': 'warn', '@typescript-eslint/no-unsafe-call': 'warn', '@typescript-eslint/no-unsafe-argument': 'warn', diff --git a/packages/cli/lib/services/__snapshots__/model.service.unit.test.ts.snap b/packages/cli/lib/services/__snapshots__/model.service.unit.test.ts.snap index dfd21c30800..54fa55df0c6 100644 --- a/packages/cli/lib/services/__snapshots__/model.service.unit.test.ts.snap +++ b/packages/cli/lib/services/__snapshots__/model.service.unit.test.ts.snap @@ -277,9 +277,6 @@ interface RunArgs { optionalEnvironment?: string; optionalProviderConfigKey?: string; } -export interface DryRunServiceInterface { - run: (options: RunArgs, debug?: boolean) => Promise; -} export interface NangoProps { scriptType: 'sync' | 'action' | 'webhook' | 'on-event'; host?: string; @@ -312,7 +309,6 @@ export interface NangoProps { rawDeleteOutput?: Map | undefined; stubbedMetadata?: Metadata | undefined; abortSignal?: AbortSignal; - dryRunService?: DryRunServiceInterface; syncConfig: DBSyncConfig; runnerFlags: RunnerFlags; debug: boolean; @@ -347,7 +343,6 @@ export declare class NangoAction { syncJobId?: number; dryRun?: boolean; abortSignal?: AbortSignal; - dryRunService?: DryRunServiceInterface; syncConfig?: DBSyncConfig; runnerFlags: RunnerFlags; connectionId: string; diff --git a/packages/cli/lib/services/dryrun.service.ts b/packages/cli/lib/services/dryrun.service.ts index 8872b7e3baf..dc38e9e9340 100644 --- a/packages/cli/lib/services/dryrun.service.ts +++ b/packages/cli/lib/services/dryrun.service.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ import promptly from 'promptly'; import fs from 'node:fs'; import { AxiosError } from 'axios'; @@ -27,8 +26,8 @@ interface RunArgs extends GlobalOptions { connectionId: string; lastSyncDate?: string; useServerLastSyncDate?: boolean; - input?: unknown; - metadata?: Metadata; + input?: string; + metadata?: string; optionalEnvironment?: string; optionalProviderConfigKey?: string; saveResponses?: boolean; @@ -222,8 +221,8 @@ export class DryRunService { let normalizedInput; if (actionInput) { - if (actionInput.toString().includes('@') && actionInput.toString().endsWith('.json')) { - const fileContents = readFile(actionInput.toString()); + if (actionInput.startsWith('@') && actionInput.endsWith('.json')) { + const fileContents = readFile(actionInput); if (!fileContents) { console.log(chalk.red('The file could not be read. Please make sure it exists.')); return; @@ -236,9 +235,9 @@ export class DryRunService { } } else { try { - normalizedInput = JSON.parse(actionInput as string); + normalizedInput = JSON.parse(actionInput); } catch { - normalizedInput = actionInput; + throw new Error('Failed to parse --input'); } } @@ -253,8 +252,8 @@ export class DryRunService { } if (rawStubbedMetadata) { - if (rawStubbedMetadata.toString().includes('@') && rawStubbedMetadata.toString().endsWith('.json')) { - const fileContents = readFile(rawStubbedMetadata.toString()); + if (rawStubbedMetadata.startsWith('@') && rawStubbedMetadata.endsWith('.json')) { + const fileContents = readFile(rawStubbedMetadata); if (!fileContents) { console.log(chalk.red('The metadata file could not be read. Please make sure it exists.')); return; @@ -267,9 +266,9 @@ export class DryRunService { } } else { try { - stubbedMetadata = JSON.parse(rawStubbedMetadata as unknown as string); + stubbedMetadata = JSON.parse(rawStubbedMetadata); } catch { - stubbedMetadata = rawStubbedMetadata; + throw new Error('fail to parse --metadata'); } } } @@ -341,6 +340,7 @@ export class DryRunService { }; } console.log('---'); + const results = await this.runScript({ syncName, nangoProps, diff --git a/packages/cli/lib/services/sdk.ts b/packages/cli/lib/services/sdk.ts index 1b85c076e67..d163c3804d2 100644 --- a/packages/cli/lib/services/sdk.ts +++ b/packages/cli/lib/services/sdk.ts @@ -2,8 +2,9 @@ import { Nango } from '@nangohq/node'; import type { ProxyConfiguration } from '@nangohq/runner-sdk'; import { InvalidRecordSDKError, NangoActionBase, NangoSyncBase } from '@nangohq/runner-sdk'; import type { AdminAxiosProps } from '@nangohq/node'; -import type { DryRunServiceInterface, Metadata, NangoProps, UserLogParameters } from '@nangohq/types'; +import type { Metadata, NangoProps, UserLogParameters } from '@nangohq/types'; import type { AxiosResponse } from 'axios'; +import type { DryRunService } from './dryrun.service'; const logLevelToLogger = { info: 'info', @@ -17,10 +18,10 @@ const logLevelToLogger = { export class NangoActionCLI extends NangoActionBase { nango: Nango; - dryRunService: DryRunServiceInterface; + dryRunService: DryRunService; dryRun = true; - constructor(props: NangoProps, cliProps: { dryRunService: DryRunServiceInterface }) { + constructor(props: NangoProps, cliProps: { dryRunService: DryRunService }) { super(props); this.dryRunService = cliProps.dryRunService; @@ -87,7 +88,7 @@ export class NangoActionCLI extends NangoActionBase { export class NangoSyncCLI extends NangoSyncBase { nango: Nango; - dryRunService: DryRunServiceInterface; + dryRunService: DryRunService; dryRun = true; logMessages: { counts: { updated: number; added: number; deleted: number }; messages: unknown[] } = { @@ -99,7 +100,7 @@ export class NangoSyncCLI extends NangoSyncBase { rawDeleteOutput = new Map(); stubbedMetadata?: Metadata | undefined = undefined; - constructor(props: NangoProps, cliProps: { stubbedMetadata?: Metadata | undefined; dryRunService: DryRunServiceInterface }) { + constructor(props: NangoProps, cliProps: { stubbedMetadata?: Metadata | undefined; dryRunService: DryRunService }) { super(props); if (cliProps.stubbedMetadata) { diff --git a/packages/connect-ui/src/lib/api.ts b/packages/connect-ui/src/lib/api.ts index 5e7ccd1d54e..5762111d795 100644 --- a/packages/connect-ui/src/lib/api.ts +++ b/packages/connect-ui/src/lib/api.ts @@ -1,5 +1,4 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable @typescript-eslint/no-redundant-type-constituents */ import type { ApiError, Endpoint, GetConnectSession, GetPublicListIntegrations, GetPublicProvider } from '@nangohq/types'; diff --git a/packages/database/lib/migrations/20240611155149_migrate_external_webhooks_table.cjs b/packages/database/lib/migrations/20240611155149_migrate_external_webhooks_table.cjs index 054e14ae990..6b9436ff3af 100644 --- a/packages/database/lib/migrations/20240611155149_migrate_external_webhooks_table.cjs +++ b/packages/database/lib/migrations/20240611155149_migrate_external_webhooks_table.cjs @@ -3,7 +3,6 @@ exports.config = { transaction: false }; exports.up = async function (knex) { let id = 0; - // eslint-disable-next-line no-constant-condition while (true) { const environments = await knex.select('*').from('_nango_environments').where('id', '>', id).orderBy('id').limit(100); diff --git a/packages/persist/lib/tracer.ts b/packages/persist/lib/tracer.ts index 9f3137100ee..42228eca670 100644 --- a/packages/persist/lib/tracer.ts +++ b/packages/persist/lib/tracer.ts @@ -11,5 +11,5 @@ tracer.use('elasticsearch', { }); tracer.use('express'); tracer.use('dns', { - enabled: false + enabled: true }); diff --git a/packages/runner-sdk/models.d.ts b/packages/runner-sdk/models.d.ts index 990ee4fc41a..aec402bf741 100644 --- a/packages/runner-sdk/models.d.ts +++ b/packages/runner-sdk/models.d.ts @@ -234,9 +234,6 @@ interface RunArgs { optionalEnvironment?: string; optionalProviderConfigKey?: string; } -export interface DryRunServiceInterface { - run: (options: RunArgs, debug?: boolean) => Promise; -} export interface NangoProps { scriptType: 'sync' | 'action' | 'webhook' | 'on-event'; host?: string; @@ -269,7 +266,6 @@ export interface NangoProps { rawDeleteOutput?: Map | undefined; stubbedMetadata?: Metadata | undefined; abortSignal?: AbortSignal; - dryRunService?: DryRunServiceInterface; syncConfig: DBSyncConfig; runnerFlags: RunnerFlags; debug: boolean; @@ -304,7 +300,6 @@ export declare class NangoAction { syncJobId?: number; dryRun?: boolean; abortSignal?: AbortSignal; - dryRunService?: DryRunServiceInterface; syncConfig?: DBSyncConfig; runnerFlags: RunnerFlags; connectionId: string; diff --git a/packages/runner/lib/idle.ts b/packages/runner/lib/idle.ts index 2dc42be25c4..52f7e1754f9 100644 --- a/packages/runner/lib/idle.ts +++ b/packages/runner/lib/idle.ts @@ -10,7 +10,7 @@ export async function idle(): Promise> { try { await retryWithBackoff( async () => { - return await httpFetch({ + await httpFetch({ method: 'POST', url: `${jobsServiceUrl}/runners/${envs.RUNNER_NODE_ID}/idle` }); diff --git a/packages/runner/lib/register.ts b/packages/runner/lib/register.ts index 7d0d15b341d..1e00d07698f 100644 --- a/packages/runner/lib/register.ts +++ b/packages/runner/lib/register.ts @@ -13,7 +13,7 @@ export async function register(): Promise> { try { await retryWithBackoff( async () => { - return await httpFetch({ + await httpFetch({ method: 'POST', url: `${jobsServiceUrl}/runners/${envs.RUNNER_NODE_ID}/register`, data: JSON.stringify({ url: envs.RUNNER_URL }) diff --git a/packages/scheduler/lib/workers/cleanup/cleanup.worker.ts b/packages/scheduler/lib/workers/cleanup/cleanup.worker.ts index 97aaa89868c..7e1e185672c 100644 --- a/packages/scheduler/lib/workers/cleanup/cleanup.worker.ts +++ b/packages/scheduler/lib/workers/cleanup/cleanup.worker.ts @@ -79,7 +79,7 @@ export class CleanupChild { async start(): Promise { logger.info('Starting cleanup...'); - // eslint-disable-next-line no-constant-condition + while (!this.cancelled) { await this.clean(); await setTimeout(this.tickIntervalMs); diff --git a/packages/scheduler/lib/workers/monitor/monitor.worker.ts b/packages/scheduler/lib/workers/monitor/monitor.worker.ts index a2c816ee5e1..70febd981b6 100644 --- a/packages/scheduler/lib/workers/monitor/monitor.worker.ts +++ b/packages/scheduler/lib/workers/monitor/monitor.worker.ts @@ -78,7 +78,7 @@ export class MonitorChild { async start(): Promise { logger.info('Starting monitor...'); - // eslint-disable-next-line no-constant-condition + while (!this.cancelled) { await this.expires(); await setTimeout(this.tickIntervalMs); diff --git a/packages/scheduler/lib/workers/scheduling/scheduling.worker.ts b/packages/scheduler/lib/workers/scheduling/scheduling.worker.ts index e9a2725a415..ac0fcac1991 100644 --- a/packages/scheduler/lib/workers/scheduling/scheduling.worker.ts +++ b/packages/scheduler/lib/workers/scheduling/scheduling.worker.ts @@ -82,7 +82,7 @@ export class SchedulingChild { async start(): Promise { logger.info('Starting scheduling...'); - // eslint-disable-next-line no-constant-condition + while (!this.cancelled) { await this.schedule(); await setTimeout(this.tickIntervalMs); diff --git a/packages/server/lib/controllers/v1/connect/sessions/postConnectSessions.ts b/packages/server/lib/controllers/v1/connect/sessions/postConnectSessions.ts index d3026227980..abcfb68985f 100644 --- a/packages/server/lib/controllers/v1/connect/sessions/postConnectSessions.ts +++ b/packages/server/lib/controllers/v1/connect/sessions/postConnectSessions.ts @@ -28,7 +28,7 @@ export const postInternalConnectSessions = asyncWrapper { let cursor = undefined; const limit = 1000; - // eslint-disable-next-line no-constant-condition + while (true) { const staleConnections = await connectionService.getStaleConnections({ days: 1, limit, cursor }); logger.info(`${cronName} found ${staleConnections.length} stale connections`); diff --git a/packages/server/lib/webhook/checkr-webhook-routing.ts b/packages/server/lib/webhook/checkr-webhook-routing.ts index 8adfdc4e6fa..e2ff2912927 100644 --- a/packages/server/lib/webhook/checkr-webhook-routing.ts +++ b/packages/server/lib/webhook/checkr-webhook-routing.ts @@ -28,6 +28,10 @@ function validate(integration: ProviderConfig, headerSignature: string, rawBody: const route: WebhookHandler = async (nango, integration, headers, body, rawBody, logContextGetter: LogContextGetter) => { const signature = headers['x-checkr-signature']; + if (!signature) { + logger.error('missing signature', { configId: integration.id }); + return; + } logger.info('received', { configId: integration.id }); diff --git a/packages/server/lib/webhook/hubspot-webhook-routing.unit.test.ts b/packages/server/lib/webhook/hubspot-webhook-routing.unit.test.ts index cb830672e0d..83dcf266b6a 100644 --- a/packages/server/lib/webhook/hubspot-webhook-routing.unit.test.ts +++ b/packages/server/lib/webhook/hubspot-webhook-routing.unit.test.ts @@ -96,7 +96,7 @@ describe('Webhook route unit tests', () => { const createdHash = crypto.createHash('sha256').update(combinedSignature).digest('hex'); const headers = { 'x-hubspot-signature': createdHash }; - await HubspotWebhookRouting.default(nangoMock as unknown as Nango, integration as ProviderConfig, headers, body, body.toString(), logContextGetter); + await HubspotWebhookRouting.default(nangoMock as unknown as Nango, integration as ProviderConfig, headers, body, '', logContextGetter); expect(nangoMock.executeScriptForWebhooks).toHaveBeenCalledTimes(body.length); @@ -149,7 +149,7 @@ describe('Webhook route unit tests', () => { const createdHash = crypto.createHash('sha256').update(combinedSignature).digest('hex'); const headers = { 'x-hubspot-signature': createdHash }; - await HubspotWebhookRouting.default(nangoMock as unknown as Nango, integration as ProviderConfig, headers, body, body.toString(), logContextGetter); + await HubspotWebhookRouting.default(nangoMock as unknown as Nango, integration as ProviderConfig, headers, body, '', logContextGetter); expect(nangoMock.executeScriptForWebhooks).toHaveBeenCalledTimes(body.length); diff --git a/packages/server/lib/webhook/internal-nango.ts b/packages/server/lib/webhook/internal-nango.ts index 0b909cd625d..05aeabc2d31 100644 --- a/packages/server/lib/webhook/internal-nango.ts +++ b/packages/server/lib/webhook/internal-nango.ts @@ -8,7 +8,7 @@ export interface InternalNango { getWebhooks: (environment_id: number, nango_config_id: number) => Promise; executeScriptForWebhooks( integration: ProviderConfig, - body: any, + body: Record, webhookType: string, connectionIdentifier: string, logContextGetter: LogContextGetter, diff --git a/packages/server/lib/webhook/linear-webhook-routing.ts b/packages/server/lib/webhook/linear-webhook-routing.ts index d157f3cd85e..77a40e05ea9 100644 --- a/packages/server/lib/webhook/linear-webhook-routing.ts +++ b/packages/server/lib/webhook/linear-webhook-routing.ts @@ -25,6 +25,10 @@ function validate(integration: ProviderConfig, headerSignature: string, rawBody: const route: WebhookHandler = async (nango, integration, headers, body, rawBody, logContextGetter: LogContextGetter) => { const signature = headers['linear-signature']; + if (!signature) { + logger.error('missing signature', { configId: integration.id }); + return; + } logger.info('received', { configId: integration.id }); diff --git a/packages/server/lib/webhook/types.ts b/packages/server/lib/webhook/types.ts index 359b0cee27b..82da1bf95ea 100644 --- a/packages/server/lib/webhook/types.ts +++ b/packages/server/lib/webhook/types.ts @@ -5,7 +5,7 @@ import type { InternalNango } from './internal-nango.js'; export type WebhookHandler = ( internalNango: InternalNango, integration: ProviderConfig, - headers: Record, + headers: Record, body: T, rawBody: string, logContextGetter: LogContextGetter diff --git a/packages/shared/lib/utils/error.ts b/packages/shared/lib/utils/error.ts index 9eea2d8f570..69958535f8e 100644 --- a/packages/shared/lib/utils/error.ts +++ b/packages/shared/lib/utils/error.ts @@ -337,7 +337,7 @@ export class NangoError extends Error { case 'generic_error_support': this.status = 500; - this.message = 'An error occurred. Please contact support with this unique id: ' + this.payload; + this.message = `An error occurred. Please contact support with this unique id: ${JSON.stringify(this.payload)}`; break; case 'sync_interval_too_short': @@ -454,7 +454,7 @@ export class NangoError extends Error { case 'deploy_missing_json_schema_model': this.status = 400; - this.message = String(this.payload); + this.message = JSON.stringify(this.payload); break; case 'invalid_action_input': @@ -504,7 +504,7 @@ export class NangoError extends Error { case 'wsse_token_generation_error': this.status = 500; - this.message = `An error occured while generating an WSSE token`; + this.message = `An error occurred while generating an WSSE token`; break; case 'script_aborted': diff --git a/packages/types/lib/runner/sdk.ts b/packages/types/lib/runner/sdk.ts index 1b234e63ed3..6d1d626e48f 100644 --- a/packages/types/lib/runner/sdk.ts +++ b/packages/types/lib/runner/sdk.ts @@ -17,10 +17,6 @@ export interface RunArgs { optionalProviderConfigKey?: string; } -export interface DryRunServiceInterface { - run: (options: RunArgs, debug?: boolean) => Promise; -} - export interface NangoProps { scriptType: 'sync' | 'action' | 'webhook' | 'on-event'; host?: string; diff --git a/packages/webapp/src/pages/Environment/Settings.tsx b/packages/webapp/src/pages/Environment/Settings.tsx index 5ffa7594636..9d1b69c8750 100644 --- a/packages/webapp/src/pages/Environment/Settings.tsx +++ b/packages/webapp/src/pages/Environment/Settings.tsx @@ -310,7 +310,7 @@ export const EnvironmentSettings: React.FC = () => { const [[, header], [, value]] = entries.slice(i, i + 2); newOtlpHeaders = { ...newOtlpHeaders, - [header.toString()]: value + [JSON.stringify(header)]: value }; } return newOtlpHeaders; diff --git a/packages/webapp/src/pages/GettingStarted/Show.tsx b/packages/webapp/src/pages/GettingStarted/Show.tsx index 57f6d59f2a8..681d66b605c 100644 --- a/packages/webapp/src/pages/GettingStarted/Show.tsx +++ b/packages/webapp/src/pages/GettingStarted/Show.tsx @@ -38,7 +38,7 @@ export const GettingStarted: React.FC = () => { try { analyticsTrack('web:getting_started:video:play'); // @ts-expect-error I don't understand - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + new window.YT.Player('player', { height: '100%', width: '100%', diff --git a/packages/webhooks/lib/auth.unit.test.ts b/packages/webhooks/lib/auth.unit.test.ts index 1caf0577468..d370577a2ee 100644 --- a/packages/webhooks/lib/auth.unit.test.ts +++ b/packages/webhooks/lib/auth.unit.test.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/unbound-method */ import { vi, expect, describe, it, beforeEach } from 'vitest'; import { sendAuth } from './auth.js'; import { axiosInstance } from '@nangohq/utils'; diff --git a/packages/webhooks/lib/forward.unit.test.ts b/packages/webhooks/lib/forward.unit.test.ts index 9b11f0c72bc..3e0df8072d9 100644 --- a/packages/webhooks/lib/forward.unit.test.ts +++ b/packages/webhooks/lib/forward.unit.test.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/unbound-method */ import { vi, expect, describe, it, beforeEach } from 'vitest'; import { sendAuth } from './auth.js'; import { axiosInstance } from '@nangohq/utils'; diff --git a/scripts/one-off/webhook-settings-migration/migrate.ts b/scripts/one-off/webhook-settings-migration/migrate.ts index ff147ccd495..67bbc455e8e 100755 --- a/scripts/one-off/webhook-settings-migration/migrate.ts +++ b/scripts/one-off/webhook-settings-migration/migrate.ts @@ -6,7 +6,6 @@ async function migrate() { let id = 0; - // eslint-disable-next-line no-constant-condition while (true) { const environments = await database.knex.select('*').from('_nango_environments').where('id', '>', id).orderBy('id').limit(1000); diff --git a/scripts/runner-update-env.js b/scripts/runner-update-env.js index 90270db387d..92000f33803 100755 --- a/scripts/runner-update-env.js +++ b/scripts/runner-update-env.js @@ -40,7 +40,6 @@ async function fetchRunners() { let services = []; let cursor = ''; - // eslint-disable-next-line no-constant-condition while (true) { const params = new URLSearchParams({ limit: 100, From 96bb4ffead9ffc3de3aba992915cc9368a23a4d0 Mon Sep 17 00:00:00 2001 From: Samuel Bodin <1637651+bodinsamuel@users.noreply.github.com> Date: Thu, 30 Jan 2025 11:01:51 +0100 Subject: [PATCH 2/3] more --- eslint.config.mjs | 2 +- packages/shared/lib/services/connection.service.ts | 2 +- packages/webapp/src/utils/api.tsx | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index d3637c1cc17..1f8dcfee23f 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -124,7 +124,7 @@ export default tseslint.config( '@typescript-eslint/restrict-plus-operands': 'warn', '@typescript-eslint/consistent-type-exports': 'error', '@typescript-eslint/no-unnecessary-condition': 'off', - '@typescript-eslint/only-throw-error': 'warn', + '@typescript-eslint/only-throw-error': 'error', '@typescript-eslint/no-unused-vars': [ 'error', diff --git a/packages/shared/lib/services/connection.service.ts b/packages/shared/lib/services/connection.service.ts index 381a5f40e70..3384803566d 100644 --- a/packages/shared/lib/services/connection.service.ts +++ b/packages/shared/lib/services/connection.service.ts @@ -1197,7 +1197,7 @@ class ConnectionService { const { success, error, response: connection } = await this.getConnection(connectionId, providerConfigKey, environmentId); if (!success || !connection) { - throw error; + throw error as NangoError; } const shouldRefresh = await this.shouldRefreshCredentials( diff --git a/packages/webapp/src/utils/api.tsx b/packages/webapp/src/utils/api.tsx index 169f059c243..f30d5276475 100644 --- a/packages/webapp/src/utils/api.tsx +++ b/packages/webapp/src/utils/api.tsx @@ -27,6 +27,7 @@ export async function swrFetcher(url: string, req?: RequestInit): Promise const res = await apiFetch(url, req); if (!res.ok) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/only-throw-error throw { json: await res.json(), status: res.status }; } From 495cb971ac47c8aa9d913d019eab5c02b5616b32 Mon Sep 17 00:00:00 2001 From: Samuel Bodin <1637651+bodinsamuel@users.noreply.github.com> Date: Thu, 30 Jan 2025 17:00:06 +0100 Subject: [PATCH 3/3] better fix --- packages/webapp/src/pages/Environment/Settings.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/webapp/src/pages/Environment/Settings.tsx b/packages/webapp/src/pages/Environment/Settings.tsx index 9d1b69c8750..9ea2491e0f3 100644 --- a/packages/webapp/src/pages/Environment/Settings.tsx +++ b/packages/webapp/src/pages/Environment/Settings.tsx @@ -308,9 +308,13 @@ export const EnvironmentSettings: React.FC = () => { const entries = Array.from(formData.entries()); for (let i = 0; i < entries.length - 1; i = i + 2) { const [[, header], [, value]] = entries.slice(i, i + 2); + if (typeof header !== 'string') { + continue; + } + newOtlpHeaders = { ...newOtlpHeaders, - [JSON.stringify(header)]: value + [header]: value }; } return newOtlpHeaders;