Skip to content

Commit

Permalink
Merge branch 'release/v5.0' into bugfix/roll-back-experiment-controll…
Browse files Browse the repository at this point in the history
…er-endpoint-validation
  • Loading branch information
danoswaltCL authored Oct 11, 2023
2 parents d41dc81 + fbbb05e commit 5a165f7
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
import {
JsonController,
Post,
Body,
UseBefore,
Get,
Req,
InternalServerError,
Delete,
} from 'routing-controllers';
import { JsonController, Post, Body, UseBefore, Get, Req, InternalServerError, Delete } from 'routing-controllers';
import { ExperimentService } from '../services/ExperimentService';
import { ExperimentAssignmentService } from '../services/ExperimentAssignmentService';
import { MarkExperimentValidator } from './validators/MarkExperimentValidator';
Expand Down Expand Up @@ -178,7 +169,7 @@ export class ExperimentClientController {
public async init(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
experimentUser: ExperimentUserValidator
): Promise<Pick<ExperimentUser, 'id' | 'group' | 'workingGroup'>> {
request.logger.info({ message: 'Starting the init call for user' });
Expand Down Expand Up @@ -255,7 +246,7 @@ export class ExperimentClientController {
public async setGroupMemberShip(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
experimentUser: ExperimentUserValidator
): Promise<ExperimentUser> {
request.logger.info({ message: 'Starting the groupmembership call for user' });
Expand Down Expand Up @@ -318,7 +309,7 @@ export class ExperimentClientController {
public async setWorkingGroup(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
workingGroupParams: UpdateWorkingGroupValidator
): Promise<ExperimentUser> {
request.logger.info({ message: 'Starting the workinggroup call for user' });
Expand Down Expand Up @@ -421,7 +412,7 @@ export class ExperimentClientController {
public async markExperimentPoint(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
experiment: MarkExperimentValidator
): Promise<MonitoredDecisionPoint> {
request.logger.info({ message: 'Starting the markExperimentPoint call for user' });
Expand Down Expand Up @@ -542,7 +533,7 @@ export class ExperimentClientController {
public async getAllExperimentConditions(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
experiment: ExperimentAssignmentValidator
): Promise<IExperimentAssignment[]> {
request.logger.info({ message: 'Starting the getAllExperimentConditions call for user' });
Expand Down Expand Up @@ -636,7 +627,7 @@ export class ExperimentClientController {
public async log(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
logData: LogValidator
): Promise<Log[]> {
request.logger.info({ message: 'Starting the log call for user' });
Expand Down Expand Up @@ -679,7 +670,7 @@ export class ExperimentClientController {
public async caliperLog(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
envelope: CaliperLogEnvelope
): Promise<Log[]> {
const result = envelope.data.map(async (log) => {
Expand Down Expand Up @@ -804,7 +795,7 @@ export class ExperimentClientController {
public async failedExperimentPoint(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
errorBody: FailedParamsValidator
): Promise<ExperimentError> {
const experimentUserDoc = await this.getUserDoc(errorBody.userId, request.logger);
Expand Down Expand Up @@ -873,7 +864,7 @@ export class ExperimentClientController {
public async filterMetrics(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
metric: MetricValidator
): Promise<Metric[]> {
return await this.metricService.saveAllMetrics(metric.metricUnit, request.logger);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export class ExperimentClientController {
public async init(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
experimentUser: ExperimentUserValidator
): Promise<Pick<ExperimentUser, 'id' | 'group' | 'workingGroup'>> {
request.logger.info({ message: 'Starting the init call for user' });
Expand Down Expand Up @@ -252,7 +252,7 @@ export class ExperimentClientController {
public async setGroupMemberShip(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
experimentUser: ExperimentUserValidator
): Promise<IGroupMembership> {
request.logger.info({ message: 'Starting the groupmembership call for user' });
Expand Down Expand Up @@ -320,7 +320,7 @@ export class ExperimentClientController {
public async setWorkingGroup(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
workingGroupParams: UpdateWorkingGroupValidator
): Promise<IWorkingGroup> {
request.logger.info({ message: 'Starting the workinggroup call for user' });
Expand Down Expand Up @@ -499,7 +499,7 @@ export class ExperimentClientController {
public async getAllExperimentConditions(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
experiment: ExperimentAssignmentValidator
): Promise<IExperimentAssignment[]> {
request.logger.info({ message: 'Starting the getAllExperimentConditions call for user' });
Expand Down Expand Up @@ -592,7 +592,7 @@ export class ExperimentClientController {
public async log(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
logData: LogValidator
): Promise<Omit<Log, 'createdAt' | 'updatedAt' | 'versionNumber'>[]> {
request.logger.info({ message: 'Starting the log call for user' });
Expand Down Expand Up @@ -636,7 +636,7 @@ export class ExperimentClientController {
*/
@Post('log/caliper')
public async caliperLog(
@Body({ validate: true })
@Body({ validate: false })
@Req()
request: AppRequest,
envelope: CaliperLogEnvelope
Expand Down Expand Up @@ -763,7 +763,7 @@ export class ExperimentClientController {
public async failedExperimentPoint(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
errorBody: FailedParamsValidator
): Promise<ExperimentError> {
const experimentUserDoc = await this.getUserDoc(errorBody.userId, request.logger);
Expand Down Expand Up @@ -832,7 +832,7 @@ export class ExperimentClientController {
public async filterMetrics(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
metric: MetricValidator
): Promise<Metric[]> {
return await this.metricService.saveAllMetrics(metric.metricUnit, request.logger);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export class ExperimentClientController {
public async init(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
experimentUser: ExperimentUserValidator
): Promise<Pick<ExperimentUser, 'id' | 'group' | 'workingGroup'>> {
request.logger.info({ message: 'Starting the init call for user' });
Expand Down Expand Up @@ -251,7 +251,7 @@ export class ExperimentClientController {
public async setGroupMemberShip(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
experimentUser: ExperimentUserValidator
): Promise<IGroupMembership> {
request.logger.info({ message: 'Starting the groupmembership call for user' });
Expand Down Expand Up @@ -319,7 +319,7 @@ export class ExperimentClientController {
public async setWorkingGroup(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
workingGroupParams: UpdateWorkingGroupValidator
): Promise<IWorkingGroup> {
request.logger.info({ message: 'Starting the workinggroup call for user' });
Expand Down Expand Up @@ -414,7 +414,7 @@ export class ExperimentClientController {
public async markExperimentPoint(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
experiment: MarkExperimentValidatorv4
): Promise<IMonitoredDecisionPoint> {
request.logger.info({ message: 'Starting the markExperimentPoint call for user' });
Expand Down Expand Up @@ -499,7 +499,7 @@ export class ExperimentClientController {
public async getAllExperimentConditions(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
experiment: ExperimentAssignmentValidator
): Promise<IExperimentAssignmentv4[]> {
request.logger.info({ message: 'Starting the getAllExperimentConditions call for user' });
Expand Down Expand Up @@ -612,7 +612,7 @@ export class ExperimentClientController {
public async log(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
logData: LogValidator
): Promise<Omit<Log, 'createdAt' | 'updatedAt' | 'versionNumber'>[]> {
request.logger.info({ message: 'Starting the log call for user' });
Expand Down Expand Up @@ -656,7 +656,7 @@ export class ExperimentClientController {
*/
@Post('log/caliper')
public async caliperLog(
@Body({ validate: true })
@Body({ validate: false })
envelope: CaliperLogEnvelope,
@Req()
request: AppRequest
Expand Down Expand Up @@ -794,7 +794,7 @@ export class ExperimentClientController {
public async filterMetrics(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
metric: MetricValidator
): Promise<Metric[]> {
return await this.metricService.saveAllMetrics(metric.metricUnit, request.logger);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class ExperimentClientController {
public async init(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
experimentUser: ExperimentUserValidator
): Promise<Pick<ExperimentUser, 'id' | 'group' | 'workingGroup'>> {
request.logger.info({ message: 'Starting the init call for user' });
Expand Down Expand Up @@ -249,7 +249,7 @@ export class ExperimentClientController {
public async setGroupMemberShip(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
experimentUser: ExperimentUserValidator
): Promise<IGroupMembership> {
request.logger.info({ message: 'Starting the groupmembership call for user' });
Expand Down Expand Up @@ -317,7 +317,7 @@ export class ExperimentClientController {
public async setWorkingGroup(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
workingGroupParams: UpdateWorkingGroupValidator
): Promise<IWorkingGroup> {
request.logger.info({ message: 'Starting the workinggroup call for user' });
Expand Down Expand Up @@ -412,7 +412,7 @@ export class ExperimentClientController {
public async markExperimentPoint(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
experiment: MarkExperimentValidatorv5
): Promise<IMonitoredDecisionPoint> {
request.logger.info({ message: 'Starting the markExperimentPoint call for user' });
Expand Down Expand Up @@ -498,7 +498,7 @@ export class ExperimentClientController {
public async getAllExperimentConditions(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
experiment: ExperimentAssignmentValidator
): Promise<IExperimentAssignmentv5[]> {
request.logger.info({ message: 'Starting the getAllExperimentConditions call for user' });
Expand Down Expand Up @@ -616,7 +616,7 @@ export class ExperimentClientController {
public async log(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
logData: LogValidator
): Promise<Omit<Log, 'createdAt' | 'updatedAt' | 'versionNumber'>[]> {
request.logger.info({ message: 'Starting the log call for user' });
Expand Down Expand Up @@ -751,7 +751,7 @@ export class ExperimentClientController {
public async filterMetrics(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
metric: MetricValidator
): Promise<Metric[]> {
return await this.metricService.saveAllMetrics(metric.metricUnit, request.logger);
Expand Down Expand Up @@ -810,7 +810,7 @@ export class ExperimentClientController {
public async setUserAliases(
@Req()
request: AppRequest,
@Body({ validate: true })
@Body({ validate: false })
user: ExperimentUserAliasesValidator
): Promise<IUserAliases> {
const experimentUserDoc = await this.getUserDoc(user.userId, request.logger);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ export class ErrorHandlerMiddleware implements ExpressErrorMiddlewareInterface {
experimentError.request = req.body;

req.logger.error(experimentError);
experimentError.type ? await this.errorService.create(experimentError, req.logger) : await Promise.resolve(error);

// #1040
// experimentError.type ? await this.errorService.create(experimentError, req.logger) : await Promise.resolve(error);
if (!res.headersSent) {
res.statusCode = error.httpCode || 500;
res.json(error);
Expand Down

0 comments on commit 5a165f7

Please sign in to comment.