Error at request validator plugin

Hi,

My Jenkins pipeline is throwing error
TypeError: Cannot read property ‘defineFunctionEventProperties’ of undefined
at new ServerlessReqValidatorPlugin (/home/jenkins/agent/del/node_modules/serverless-reqvalidator-plugin/src/index.js:50:36)

below is content of part my serverless.yaml file with request validator and sample function referencing request validator. Can any one please suggest what am I missing. I am new to serverless and help would be appreciated.

service:
name: data-ecosystem-ingestion-services-api
awsKmsKeyArn: ${self:custom.env.kms-key}
app: data-ecosystem-ingestion-services
frameworkVersion: “>=1.1.0 <2.0.0”

plugins:

  • serverless-associate-waf
  • serverless-python-requirements
  • serverless-enable-api-logs
  • serverless-tag-api-gateway
  • serverless-plugin-log-subscription
  • serverless-reqvalidator-plugin
  • serverless-apigateway-access-logs-plugin

custom:
associateWaf:
name: FMManagedWebACL5becd3a8-4ec6-4589-bd0e-deb87d7a205f
apiGatewayTags:
AsaqId: {file(./{self:provider.stage}.env.json):AsaqId}
AssetOwner: {file(./{self:provider.stage}.env.json):AssetOwner}
CiId: {file(./{self:provider.stage}.env.json):CiId}
CostCenter: {file(./{self:provider.stage}.env.json):CostCenter}
DataSteward: {file(./{self:provider.stage}.env.json):DataSteward}
DataCustodian: {file(./{self:provider.stage}.env.json):DataCustodian}
DataClassification: {file(./{self:provider.stage}.env.json):DataClassification}
ComplianceDataCategory: {file(./{self:provider.stage}.env.json):ComplianceDataCategory}
DataOwner: {file(./{self:provider.stage}.env.json):DataOwner}
DataSubjectArea : {file(./{self:provider.stage}.env.json):DataSubjectArea}
Exception : {file(./{self:provider.stage}.env.json):Exception}
env: {file(./{self:provider.stage}.env.json)}
logSubscription:
destinationArn: {file(./{self:provider.stage}.env.json):destinationArn}
enabled: true

package:
exclude:
- node_modules/**
- .idea/**
- .requirements/**
- env/**
- README.md
- package.json
- package-lock.json
- requirements.txt

provider:
name: aws
stackTags:
AsaqId: {file(./{self:provider.stage}.env.json):AsaqId}
AssetOwner: {file(./{self:provider.stage}.env.json):AssetOwner}
CiId: {file(./{self:provider.stage}.env.json):CiId}
CostCenter: {file(./{self:provider.stage}.env.json):CostCenter}
DataSteward: {file(./{self:provider.stage}.env.json):DataSteward}
DataCustodian: {file(./{self:provider.stage}.env.json):DataCustodian}
DataClassification: {file(./{self:provider.stage}.env.json):DataClassification}
ComplianceDataCategory: {file(./{self:provider.stage}.env.json):ComplianceDataCategory}
DataOwner: {file(./{self:provider.stage}.env.json):DataOwner}
DataSubjectArea : {file(./{self:provider.stage}.env.json):DataSubjectArea}
Exception : {file(./{self:provider.stage}.env.json):Exception}
apiKeys:
- name: {opt:stage,'dev'}-apikeys versionFunctions: false apiGatewayAccessLogs: account: {self:custom.env.accountnumber}
logGroup: ${self:custom.env.loggroupname}

stage: {opt:stage,'dev'} runtime: python3.7 region: {opt:region, ‘us-east-1’}
apiName: {self:custom.env.apiname} stackName: {self:custom.env.stackname}
role: arn:aws:iam::${self:custom.env.accountnumber}:role/Enterprise/EuroLambdaExec
disableLogs: false
logRetentionInDays: 14

logs:

restApi:

roleManagedExternally: true # disables automatic role creation/checks done by Serverless

role: arn:aws:iam::${self:custom.env.accountnumber}:role/Enterprise/GlobalAPItoCloudwatchLogs

arn: arn:aws:logs:{self:custom.env.aws_region}:{self:custom.env.accountnumber}:log-group:${self:custom.env.loggroupname}

format: ‘{ “requestId”:"$context.requestId", “ip”: “$context.identity.sourceIp” }’

executionLogging: true

accessLogging: true

vpc:
securityGroupIds:
- {self:custom.env.securityGroupIds} subnetIds: - {self:custom.env.subnetIds1}
- ${self:custom.env.subnetIds2}

profile: saml
memorySize: 1024 # Overwrite the default memory size. Default is 1024
timeout: 600
deploymentBucket:
name: intl-euro-uk-system-{self:custom.env.env} maxPreviousDeploymentArtifacts: 2 environment: ENV: {self:custom.env.env}
deploymentPrefix: ingestion-services/artifacts/

resources:
Resources:
onlyBody:
Type: “AWS::ApiGateway::RequestValidator”
Properties:
Name: ‘only-body’
RestApiId:
Ref: ApiGatewayRestApi
ValidateRequestBody: true
ValidateRequestParameters: false

functions:
ping:
handler: app/ping.ping_http
events:
- awsKmsKeyArn: ${self:custom.env.kms-key}
- http:
path: ping
method: get
cors: true
private: true
reqValidatorName: onlyBody
- http:
path: ping
method: options
reqValidatorName: onlyBody

Hi avanijjain16,

You probably updated the lib: serverless-reqvalidator-plugin to version 1.0.4?
Not an ideal solution, but for now can you try to explicit go back to 1.0.3? And see if it works again then?

Maybe the plugin newer version has some compatibility issues?

Good luck,
Richard

Hey,

Plugin has been updated with verification part ( https://www.serverless.com/framework/docs/providers/aws/guide/plugins/#extending-validation-schema ) and if you are using version of framework which is older then it will throw the error mentioned.

As a fix (before you would be able to upgrade serverless ) please pin to 1.0.3 instead of latest

1 Like

Thank you for your reply. Yes this was fixed after using 1.0.3.