Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration error at 'functions.hello': unrecognized property 'custom' #8422

Closed
tolgatakir opened this issue Oct 20, 2020 · 6 comments · Fixed by #8462
Closed

Configuration error at 'functions.hello': unrecognized property 'custom' #8422

tolgatakir opened this issue Oct 20, 2020 · 6 comments · Fixed by #8462

Comments

@tolgatakir
Copy link

After serverless framework 2.6.0 version, not able to giving custom properties during function definition. 97b7a48 this change may have caused the problem.

functions:
  hello:
    handler: handler.hello
    custom:
      thundra:
        disable: true
serverless.yml
service: serverlessnode10example

frameworkVersion: '2'

configValidationMode: error

provider:
  name: aws
  runtime: nodejs10.x
  stage: dev
  region: eu-west-1

functions:
  hello:
    handler: handler.hello
    custom:
      thundra:
        disable: true

plugins:  
  - serverless-plugin-thundra
sls deploy output
Serverless Error ---------------------------------------
 
  Configuration error at 'functions.hello': unrecognized property 'custom'
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              12.18.4
     Framework Version:         2.8.0
     Plugin Version:            4.1.1
     SDK Version:               2.3.2
     Components Version:        3.2.4

Installed version

Framework Core: 2.8.0
Plugin: 4.1.1
SDK: 2.3.2
Components: 3.2.4
@fredericbarthelet
Copy link
Contributor

Hi @tolgatakir , thanks for reporting this issue.

Function definition schema validation has been enforced from v2.7.0.
Any properties not defined within function definition below will trigger validation error

function: {
properties: {
awsKmsKeyArn: { $ref: '#/definitions/awsKmsArn' },
condition: { $ref: '#/definitions/awsResourceCondition' },
dependsOn: { $ref: '#/definitions/awsResourceDependsOn' },
description: { type: 'string', maxLength: 256 },
destinations: {
type: 'object',
properties: {
onSuccess: { type: 'string', minLength: 1 },
onFailure: { type: 'string', minLength: 1 },
},
additionalProperties: false,
},
disableLogs: { type: 'boolean' },
environment: { $ref: '#/definitions/awsLambdaEnvironment' },
fileSystemConfig: {
type: 'object',
properties: {
arn: {
anyOf: [
{
type: 'string',
pattern:
'^arn:aws[a-zA-Z-]*:elasticfilesystem:[a-z]{2}((-gov)|(-iso(b?)))?-[a-z]+-[1-9]{1}:[0-9]{12}:access-point/fsap-[a-f0-9]{17}$',
},
{ $ref: '#/definitions/awsCfGetAtt' },
{ $ref: '#/definitions/awsCfJoin' },
{ $ref: '#/definitions/awsCfImport' },
],
},
localMountPath: { type: 'string', pattern: '^/mnt/[a-zA-Z0-9-_.]+$' },
},
additionalProperties: false,
required: ['localMountPath', 'arn'],
},
handler: { type: 'string' },
kmsKeyArn: { $ref: '#/definitions/awsKmsArn' },
layers: { $ref: '#/definitions/awsLambdaLayers' },
maximumEventAge: { type: 'integer', minimum: 60, maximum: 21600 },
maximumRetryAttempts: { type: 'integer', minimum: 0, maximum: 2 },
memorySize: { $ref: '#/definitions/awsLambdaMemorySize' },
onError: {
anyOf: [
{ type: 'string', pattern: '^arn:aws[a-z-]*:sns' },
{ $ref: '#/definitions/awsCfFunction' },
],
},
package: {
type: 'object',
properties: {
artifact: { type: 'string' },
exclude: { type: 'array', items: { type: 'string' } },
include: { type: 'array', items: { type: 'string' } },
individually: { type: 'boolean' },
},
additionalProperties: false,
},
provisionedConcurrency: { type: 'integer', minimum: 1 },
reservedConcurrency: { type: 'integer', minimum: 0 },
role: { $ref: '#/definitions/awsLambdaRole' },
runtime: { $ref: '#/definitions/awsLambdaRuntime' },
tags: { $ref: '#/definitions/awsResourceTags' },
timeout: { $ref: '#/definitions/awsLambdaTimeout' },
tracing: { $ref: '#/definitions/awsLambdaTracing' },
versionFunction: { $ref: '#/definitions/awsLambdaVersionning' },
vpc: { $ref: '#/definitions/awsLambdaVpcConfig' },
},
additionalProperties: false,
},

As of today, you can add in serverless.yaml root configValidationMode: off and it will disable display of those error messages. You however won't benefit from JSON schema validation for other properties of your service file.

I see the use of serverless-plugin-thundra plugin in your exemple file. Plugin developers should add definition for properties used by their plugin within their code base following https://www.serverless.com/framework/docs/providers/aws/guide/plugins/#extending-validation-schema documentation.

@medikoo, in order for the plugin team to be able to add the custom property to function base definition, they'll require the same ConfigSchemaHandler new defineFunctionProperties function than proposed in #8423 . Do you agree with this new function implementation ?

@medikoo
Copy link
Contributor

medikoo commented Oct 27, 2020

@medikoo, in order for the plugin team to be able to add the custom property to function base definition, they'll require the same ConfigSchemaHandler new defineFunctionProperties function than proposed in #8423 . Do you agree with this new function implementation

Yes, we definitely can provide defineFunctionProperties. Currently function properties can only be defined by plugins which bring new provider support, but I think there's no reason to block plugins which extend the provider implementation from defining their own function properties.

PR that brings that is definitely welcome!

@luislhl
Copy link
Contributor

luislhl commented Oct 27, 2020

I could give this a try if you think this is a good first issue and with some initial orientation. I'm also interested in this improvement.

@medikoo
Copy link
Contributor

medikoo commented Oct 28, 2020

@luislhl that'll be very welcome!

Technically it's about implementation of defineFunctionProperties (as already pointed by @fredericbarthelet) somewhere here

(there are other similar functions defined there, which should serve as a hint, otherwise I'm also happy to answer any questions)

Additionally we should ensure it's documented here: https://github.com/serverless/serverless/blob/989bd664699860f130c2172335a185b336fe04a6/docs/providers/aws/guide/plugins.md#extending-validation-schema

@luislhl
Copy link
Contributor

luislhl commented Oct 30, 2020

Great! Thanks for the introduction.

I'll dive deeper into this then, probably this weekend, and hope to bring some updates soon.

@luislhl
Copy link
Contributor

luislhl commented Oct 31, 2020

I have opened a PR on this, waiting for review: #8462

crunchie84 added a commit to crunchie84/serverless-log-forwarding that referenced this issue Jul 1, 2022
In serverless v2.7.0 schema validation of the serverless.yml has been
implemented (see serverless/serverless#8422 (comment))

Based on this you can trigger errors when parameters are referenced which
do not exist. This plugin relies on some custom properties in the serverless.yml
which caused warnings.

This commit appends the JSON schema as described in the README.md of this
plugin
crunchie84 added a commit to crunchie84/serverless-log-forwarding that referenced this issue Mar 24, 2023
In serverless v2.7.0 schema validation of the serverless.yml has been
implemented (see serverless/serverless#8422 (comment))

Based on this you can trigger errors when parameters are referenced which
do not exist. This plugin relies on some custom properties in the serverless.yml
which caused warnings.

This commit appends the JSON schema as described in the README.md of this
plugin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants