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

[BUG]: Pull request opened event JSON schema doesn't pass validation with AJV #900

Closed
1 task done
ArkadiuszKolodynski opened this issue Feb 22, 2024 · 4 comments · Fixed by #904
Closed
1 task done
Labels
released Type: Bug Something isn't working as documented

Comments

@ArkadiuszKolodynski
Copy link

What happened?

I'm using fastify with AJV with following configuration:

ajv: {
    customOptions: {
      keywords: ['tsAdditionalProperties'],
      strict: true,
      useDefaults: false,
      removeAdditional: false,
    },
    plugins: [ajvFormats],
}

I need to set removeAdditional: false in order to pass the validation of example Pull Request Opened payload from this repository. However even with that config the real payload coming from the github does not pass the validation.

Versions

Node: v20.11.0
@octokit/webhooks-schemas: v7.3.2
fastify: v4.26.1
ajv: 8.12.0

Relevant log output

{
    "statusCode": 400,
    "code": "FST_ERR_VALIDATION",
    "error": "Bad Request",
    "message": "body must have required property 'rule', body must have required property 'rule', body must have required property 'rule', body must match exactly one schema in oneOf, body must have required property 'check_run', body must have required property 'check_run', body must have required property 'check_run', body must have required property 'check_run', body must match exactly one schema in oneOf, body must have required property 'check_suite', body must have required property 'check_suite', body must have required property 'check_suite', body must match exactly one schema in oneOf, body must have required property 'alert', body must have required property 'alert', body must have required property 'alert', body must have required property 'alert', body must have required property 'alert', body must have required property 'alert', body must match exactly one schema in oneOf, body must have required property 'comment', body must match exactly one schema in oneOf, body must have required property 'ref', body must have required property 'ref', body must have required property 'alert', body must have required property 'alert', body must have required property 'alert', body must have required property 'alert', body must have required property 'alert', body must match exactly one schema in oneOf, body must have required property 'key', body must have required property 'key', body must match exactly one schema in oneOf, body must have required property 'deployment', body must match exactly one schema in oneOf, body must NOT have additional properties, body must match exactly one schema in oneOf, body must have required property 'workflow_run', body must have required property 'workflow_run', body must have required property 'environment', body must match exactly one schema in oneOf, body must have required property 'deployment_status', body must match exactly one schema in oneOf, body must have required property 'discussion', body must have required property 'changes', body must have required property 'discussion', body must have required property 'discussion', body must have required property 'discussion', body must have required property 'discussion', body must have required property 'discussion', body must have required property 'discussion', body must have required property 'changes', body must have required property 'discussion', body must have required property 'discussion', body must have required property 'discussion', body must have required property 'discussion', body must match exactly one schema in oneOf, body must have required property 'comment', body must have required property 'comment', body must have required property 'changes', body must match exactly one schema in oneOf, body must have required property 'forkee', body must NOT have additional properties, body must match exactly one schema in oneOf, body must have required property 'pages', body must NOT have additional properties, body must NOT have additional properties, body must NOT have additional properties, body must NOT have additional properties, body must NOT have additional properties, body must match exactly one schema in oneOf, body must have required property 'repository_selection', body must have required property 'repository_selection', body must match exactly one schema in oneOf, body must have required property 'target_type', body must match exactly one schema in oneOf, body must have required property 'issue', body must have required property 'issue', body must have required property 'changes', body must match exactly one schema in oneOf, body must have required property 'issue', body must have required property 'issue', body must have required property 'issue', body must have required property 'issue', body must have required property 'changes', body must have required property 'issue', body must have required property 'issue', body must have required property 'issue', body must have required property 'issue', body must have required property 'issue', body must have required property 'issue', body must have required property 'changes', body must have required property 'issue', body must have required property 'issue', body must have required property 'issue', body must have required property 'issue', body must match exactly one schema in oneOf, body must have required property 'label', body must have required property 'label', body must have required property 'label', body must match exactly one schema in oneOf, body must have required property 'effective_date', body must have required property 'effective_date', body must have required property 'effective_date', body must have required property 'effective_date', body must have required property 'effective_date', body must match exactly one schema in oneOf, body must have required property 'member', body must have required property 'changes', body must have required property 'member', body must match exactly one schema in oneOf, body must have required property 'scope', body must have required property 'scope', body must match exactly one schema in oneOf, body must have required property 'merge_group', body must match exactly one schema in oneOf, body must have required property 'hook_id', body must match exactly one schema in oneOf, body must have required property 'milestone', body must have required property 'milestone', body must have required property 'milestone', body must have required property 'changes', body must have required property 'milestone', body must match exactly one schema in oneOf, body must have required property 'blocked_user', body must have required property 'blocked_user', body must match exactly one schema in oneOf, body must NOT have additional properties, body must have required property 'membership', body must have required property 'invitation', body must have required property 'membership', body must have required property 'changes', body must match exactly one schema in oneOf, body must have required property 'package', body must have required property 'package', body must match exactly one schema in oneOf, body must have required property 'id', body must have required property 'zen', body must have required property 'project', body must have required property 'project', body must have required property 'project', body must have required property 'project', body must have required property 'project', body must match exactly one schema in oneOf, body must have required property 'changes', body must have required property 'project_card', body must have required property 'project_card', body must have required property 'changes', body must have required property 'project_card', body must match exactly one schema in oneOf, body must have required property 'project_column', body must have required property 'project_column', body must have required property 'changes', body must have required property 'project_column', body must match exactly one schema in oneOf, body must have required property 'changes', body must have required property 'changes', body must have required property 'projects_v2_item', body must have required property 'projects_v2_item', body must have required property 'changes', body must have required property 'changes', body must have required property 'changes', body must match exactly one schema in oneOf, body must NOT have additional properties, body must have required property 'assignee', body must have required property 'reason', body must have required property 'reason', body/action must be equal to one of the allowed values, body/action must be equal to one of the allowed values, body must have required property 'milestone', body must have required property 'reason', body must have required property 'changes', body/action must be equal to one of the allowed values, body must have required property 'label', body/action must be equal to one of the allowed values, body must have required property 'milestone', body/repository must NOT have additional properties, body/action must be equal to one of the allowed values, body/action must be equal to one of the allowed values, body must have required property 'requested_reviewer', body must have required property 'requested_team', body must match exactly one schema in oneOf, body must have required property 'requested_reviewer', body must have required property 'requested_team', body must match exactly one schema in oneOf, body must have required property 'before', body must have required property 'assignee', body must have required property 'label', body/action must be equal to one of the allowed values, body must match exactly one schema in oneOf, body must have required property 'review', body must have required property 'changes', body must have required property 'review', body must match exactly one schema in oneOf, body must have required property 'comment', body must have required property 'comment', body must have required property 'changes', body must match exactly one schema in oneOf, body must have required property 'thread', body must have required property 'thread', body must match exactly one schema in oneOf, body must have required property 'ref', body must have required property 'registry_package', body must have required property 'registry_package', body must match exactly one schema in oneOf, body must have required property 'release', body must have required property 'release', body must have required property 'changes', body must have required property 'release', body must have required property 'release', body must have required property 'release', body must have required property 'release', body must match exactly one schema in oneOf, body must NOT have additional properties, body must NOT have additional properties, body must NOT have additional properties, body must have required property 'changes', body must NOT have additional properties, body must NOT have additional properties, body must have required property 'changes', body must have required property 'changes', body must NOT have additional properties, body must match exactly one schema in oneOf, body must have required property 'branch', body must have required property 'status', body must have required property 'alert', body must have required property 'alert', body must have required property 'alert', body must have required property 'alert', body must match exactly one schema in oneOf, body must have required property 'alert', body must have required property 'alert', body must have required property 'alert', body must have required property 'alert', body must match exactly one schema in oneOf, body must have required property 'location', body must match exactly one schema in oneOf, body must have required property 'security_advisory', body must have required property 'security_advisory', body must have required property 'security_advisory', body must have required property 'security_advisory', body must match exactly one schema in oneOf, body must have required property 'sponsorship', body must have required property 'sponsorship', body must have required property 'changes', body must have required property 'sponsorship', body must have required property 'changes', body must have required property 'changes', body must match exactly one schema in oneOf, body must have required property 'starred_at', body must have required property 'starred_at', body must match exactly one schema in oneOf, body must have required property 'id', body must have required property 'team', body must have required property 'team', body must have required property 'team', body must have required property 'changes', body must have required property 'team', body must match exactly one schema in oneOf, body must have required property 'team', body must NOT have additional properties, body must match exactly one schema in oneOf, body must have required property 'inputs', body must have required property 'workflow_job', body must have required property 'workflow_job', body must have required property 'workflow_job', body must have required property 'workflow_job', body must match exactly one schema in oneOf, body must have required property 'workflow', body must have required property 'workflow', body must have required property 'workflow', body must match exactly one schema in oneOf, body must match exactly one schema in oneOf"
}

Code of Conduct

  • I agree to follow this project's Code of Conduct
@ArkadiuszKolodynski ArkadiuszKolodynski added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Feb 22, 2024
Copy link
Contributor

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@wolfy1339
Copy link
Member

Can you share the offending payload?

There is a new property that is present on the repository field, maybe that's it.

Also, it's best to share the raw AJV error in cases like these.

Also, you may like to implement similar code to this: https://github.com/wolfy1339/compare-gh-webhook-to-schema-function/blob/f1ae54d9bd7347b2f0a0199e46ed4dad21ed6695/src/github/EventValidator.ts#L106-L123

That way similar errors are not repeated, and errors that are similar are merged together for a more streamlined output

@ArkadiuszKolodynski
Copy link
Author

ArkadiuszKolodynski commented Feb 22, 2024

@wolfy1339 Thank you for your response. Sorry for providing fastify error output instead of raw AJV.

I compared the example payload with the real one and the property thats causing the validation error is "custom_properties": {} in the repository field.

@octokitbot
Copy link
Collaborator

🎉 This issue has been resolved in version 7.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment