Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@
"md5": "^2.3.0",
"pino": "^8.19.0",
"semver": "^7.5.4"
}
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
4 changes: 2 additions & 2 deletions src/bandit-evaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export interface BanditEvaluation {
}

export class BanditEvaluator {
private assignmentShards = BANDIT_ASSIGNMENT_SHARDS; // We just hard code this for now
private sharder: Sharder = new MD5Sharder();
private readonly assignmentShards = BANDIT_ASSIGNMENT_SHARDS; // We just hard code this for now
private readonly sharder: Sharder = new MD5Sharder();

public evaluateBandit(
flagKey: string,
Expand Down
8 changes: 7 additions & 1 deletion src/client/eppo-client-assignment-details.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { AllocationEvaluationCode } from '../flag-evaluation-details-builder';
import FetchHttpClient from '../http-client';
import { Flag, ObfuscatedFlag, Variation, VariationType } from '../interfaces';
import { OperatorType } from '../rules';
import { AttributeType } from '../types';

import EppoClient, { IAssignmentDetails } from './eppo-client';

Expand Down Expand Up @@ -345,7 +346,12 @@ describe('EppoClient get*AssignmentDetails', () => {
[VariationType.STRING]: client.getStringAssignmentDetails.bind(client),
[VariationType.JSON]: client.getJSONAssignmentDetails.bind(client),
};
const assignmentFn = typeAssignmentDetailsFunctions[variationType];
const assignmentFn = typeAssignmentDetailsFunctions[variationType] as (
flagKey: string,
subjectKey: string,
subjectAttributes: Record<string, AttributeType>,
defaultValue: boolean | string | number | object,
) => IAssignmentDetails<boolean | string | number | object>;
if (!assignmentFn) {
throw new Error(`Unknown variation type: ${variationType}`);
}
Expand Down
10 changes: 5 additions & 5 deletions src/client/eppo-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,13 +509,13 @@
);
evaluationDetails.banditAction = action;
}
} catch (err) {
} catch (err: any) {
logger.error('Error determining bandit action', err);
if (!this.isGracefulFailureMode) {
throw err;
}
if (variation) {
// If we have a variation, the assignment succeeded and the error was with the bandit part.

Check warning on line 518 in src/client/eppo-client.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk

Unexpected any. Specify a different type
// Update the flag evaluation code to indicate that
evaluationDetails.flagEvaluationCode = 'BANDIT_ERROR';
}
Expand Down Expand Up @@ -700,7 +700,7 @@
expectedVariationType,
);
return this.parseVariationWithDetails(result, defaultValue, expectedVariationType);
} catch (error) {
} catch (error: any) {
const eppoValue = this.rethrowIfNotGraceful(error, defaultValue);
if (error instanceof FlagEvaluationError && error.flagEvaluationDetails) {
return {
Expand Down Expand Up @@ -738,7 +738,7 @@
eppoValue: EppoValue.valueOf(result.variation.value, expectedVariationType),
flagEvaluationDetails: result.flagEvaluationDetails,
};
} catch (error) {
} catch (error: any) {
const eppoValue = this.rethrowIfNotGraceful(error, defaultValue);
return {
eppoValue,
Expand All @@ -752,7 +752,7 @@
logger.error(`[Eppo SDK] Error getting assignment: ${err.message}`);
return defaultValue ?? EppoValue.Null();
}
throw err;

Check warning on line 755 in src/client/eppo-client.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk

Unexpected any. Specify a different type
}

/**
Expand Down Expand Up @@ -790,7 +790,7 @@
return noneResult(flagKey, subjectKey, subjectAttributes, flagEvaluationDetails);
}

if (!checkTypeMatch(expectedVariationType, flag.variationType)) {

Check warning on line 793 in src/client/eppo-client.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk

Unexpected any. Specify a different type
const errorMessage = `Variation value does not have the correct type. Found ${flag.variationType}, but expected ${expectedVariationType} for flag ${flagKey}`;
if (this.isGracefulFailureMode) {
const flagEvaluationDetails = flagEvaluationDetailsBuilder.buildForNoneResult(
Expand Down Expand Up @@ -958,7 +958,7 @@
eventsToFlush.forEach((event) => {
try {
logFunction(event);
} catch (error) {
} catch (error: any) {
logger.error(`[Eppo SDK] Error flushing event to logger: ${error.message}`);
}
});
Expand Down Expand Up @@ -1005,12 +1005,12 @@
allocationKey: allocationKey ?? '__eppo_no_allocation',
variationKey: variation?.key ?? '__eppo_no_variation',
});
} catch (error) {
} catch (error: any) {
logger.error(`[Eppo SDK] Error logging assignment event: ${error.message}`);
}
}

private buildLoggerMetadata(): Record<string, unknown> {

Check warning on line 1013 in src/client/eppo-client.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk

Unexpected any. Specify a different type
return {
obfuscated: this.isObfuscated,
sdkLanguage: 'javascript',
Expand Down
4 changes: 2 additions & 2 deletions src/evaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
}

export class Evaluator {
sharder: Sharder;
private readonly sharder: Sharder;

constructor(sharder?: Sharder) {
this.sharder = sharder ?? new MD5Sharder();
Expand Down Expand Up @@ -133,7 +133,7 @@
'No allocations matched. Falling back to "Default Allocation", serving NULL',
),
);
} catch (err) {
} catch (err: any) {

Check warning on line 136 in src/evaluator.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk

Unexpected any. Specify a different type
const flagEvaluationDetails = flagEvaluationDetailsBuilder.gracefulBuild(
'ASSIGNMENT_ERROR',
`Assignment Error: ${err.message}`,
Expand Down
2 changes: 1 addition & 1 deletion src/http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
throw new HttpRequestError('Failed to fetch data', response?.status);
}
return await response.json();
} catch (error) {
} catch (error: any) {

Check warning on line 64 in src/http-client.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk

Unexpected any. Specify a different type
if (error.name === 'AbortError') {
throw new HttpRequestError('Request timed out', 408, error);
} else if (error instanceof HttpRequestError) {
Expand Down
4 changes: 2 additions & 2 deletions src/poller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
startRequestSuccess = true;
previousPollFailed = false;
logger.info('Eppo SDK successfully requested initial configuration');
} catch (pollingError) {
} catch (pollingError: any) {

Check warning on line 51 in src/poller.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk

Unexpected any. Specify a different type
previousPollFailed = true;
logger.warn(
`Eppo SDK encountered an error with initial poll of configurations: ${pollingError.message}`,
Expand Down Expand Up @@ -116,7 +116,7 @@
previousPollFailed = false;
logger.info('Eppo SDK poll successful; resuming normal polling');
}
} catch (error) {
} catch (error: any) {

Check warning on line 119 in src/poller.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk

Unexpected any. Specify a different type
previousPollFailed = true;
logger.warn(`Eppo SDK encountered an error polling configurations: ${error.message}`);
const maxTries = 1 + (options?.maxPollRetries ?? DEFAULT_POLL_CONFIG_REQUEST_RETRIES);
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"target": "es2017",
"outDir": "dist",
"noImplicitAny": true,
"strictNullChecks": true,
"strict": true,
"strictPropertyInitialization": true
},
"include": ["src/**/*.ts"],
Expand Down
Loading