question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom EventBridge Schema Registry - Cannot export JSONSchemaDraft4 for non discovered or non aws managed schemas

See original GitHub issue

Have you read the Contributing Guidelines on issues?

Description

When setting up the generator with a custom registryName (other than discovered-schemas), running npm run generate will yield the following exception: ForbiddenException: You cannot export non discovered or non aws managed schemas.

This seems to be due to the usage of exportSchema() on every returned schema by default (verified with Python boto3.schemas lib too).

We might need to make this feature optional or add a condition on the registryType.

Steps to reproduce

  1. Create a custom EventBridge Schema Registry
  2. Create a new Schema in your new EventBridge Schema Registry
  3. Set the generator to point to the custom EventBridge Schema Registry (registryName)
generators: [
    [
      '@eventcatalog/plugin-doc-generator-amazon-eventbridge',
      {
        eventBusName: 'MyEventBus',
        region: 'eu-west-2',
        registryName: 'MySchemaRegistry',
        schemaTypeToRenderToEvent: 'OpenAPI',
        credentials: {
          accessKeyId: process.env.AWS_ACCESS_KEY,
          secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
        },
      },
    ],
  ]
  1. Run npm run generate

Expected behavior

As for the default discovered-schemas registry, we expect listed schemas to be mapped into new events/ directories containing the templated markdown docs.

In the case of a custom EventBridge Schema Registry, the documentation could be templated without exporting the JSONSchemaDraft4 schema files.

Actual behavior

a 403 ForbiddenException: You cannot export non discovered or non aws managed schemas exception is thrown.

Generating EventCatalog docs using: @eventcatalog/plugin-doc-generator-amazon-eventbridge
/Users/john/my-event-catalog/node_modules/@aws-sdk/client-schemas/dist-cjs/protocols/Aws_restJson1.js:2888
    const exception = new models_0_1.ForbiddenException({
                      ^

ForbiddenException: You cannot export non discovered or non aws managed schemas.
    at deserializeAws_restJson1ForbiddenExceptionResponse (/Users/john/my-event-catalog/node_modules/@aws-sdk/client-schemas/dist-cjs/protocols/Aws_restJson1.js:2888:23)
    at deserializeAws_restJson1ExportSchemaCommandError (/Users/john/my-event-catalog/node_modules/@aws-sdk/client-schemas/dist-cjs/protocols/Aws_restJson1.js:1815:25)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /Users/john/my-event-catalog/node_modules/@aws-sdk/middleware-serde/dist-cjs/deserializerMiddleware.js:7:24
    at async /Users/john/my-event-catalog/node_modules/@aws-sdk/middleware-signing/dist-cjs/middleware.js:11:20
    at async StandardRetryStrategy.retry (/Users/john/my-event-catalog/node_modules/@aws-sdk/middleware-retry/dist-cjs/StandardRetryStrategy.js:51:46)
    at async /Users/john/my-event-catalog/node_modules/@aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:6:22
    at async /Users/john/my-event-catalog/node_modules/@eventcatalog/plugin-doc-generator-amazon-eventbridge/lib/lib/aws.js:12:30
    at async Promise.all (index 0)
    at async exports.default (/Users/john/my-event-catalog/node_modules/@eventcatalog/plugin-doc-generator-amazon-eventbridge/lib/index.js:38:21) {
  '$fault': 'client',
  '$metadata': {
    httpStatusCode: 403,
    requestId: '4526e20b-4fbd-44a9-9a72-4bd4d427e791',
    extendedRequestId: undefined,
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  },
  Code: 'Forbidden'
}
Error: Command failed: cross-env PROJECT_DIR=/Users/john/my-event-catalog npm run generate
    at checkExecSyncError (node:child_process:826:11)
    at execSync (node:child_process:900:15)
    at Command.<anonymous> (/Users/john/my-event-catalog/node_modules/@eventcatalog/core/bin/eventcatalog.js:108:5)
    at Command.listener [as _actionHandler] (/Users/john/my-event-catalog/node_modules/commander/index.js:922:31)
    at Command._parseCommand (/Users/john/my-event-catalog/node_modules/commander/index.js:1503:14)
    at Command._dispatchSubcommand (/Users/john/my-event-catalog/node_modules/commander/index.js:1443:18)
    at Command._parseCommand (/Users/john/my-event-catalog/node_modules/commander/index.js:1460:12)
    at Command.parse (/Users/john/my-event-catalog/node_modules/commander/index.js:1292:10)
    at run (/Users/john/my-event-catalog/node_modules/@eventcatalog/core/bin/eventcatalog.js:115:7)
    at Object.<anonymous> (/Users/john/my-event-catalog/node_modules/@eventcatalog/core/bin/eventcatalog.js:122:1) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 36420,
  stdout: null,
  stderr: null
}

Your environment

  • EventCatalog version used: 0.0.6
  • Environment name and version: Chrome 100.0.4896.127, Node.js 16.13.2
  • Operating system and version: MacOS 12.3.1

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
boyney123commented, May 23, 2022

Hey @frenayj ,

Yeah this is very interesting indeed! Will take a look around and explore abit more, but as you said if we cannot get it I think having some condition in there would be good too. Guess would mean less hydration for you, but would make things work…

0reactions
boyney123commented, Jul 7, 2022

Ah o no @frenayj , any idea what kind of issues you were seeing?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating an Amazon EventBridge schema
Create a schema from the JSON of an event · In the navigation pane, choose Schemas and then choose Create schema. · (Optional)...
Read more >
Amazon EventBridge schemas - AWS Documentation
A schema defines the structure of events that are sent to EventBridge. EventBridge provides schemas for all events that are generated by AWS...
Read more >
Welcome - Amazon EventBridge Schemas
The Amazon EventBridge Schema Registry allows you to discover, create, and manage OpenAPI schemas for events on EventBridge.
Read more >
Working with events and the Amazon EventBridge schema ...
There are three types of schemas represented in the tabs: AWS event schema registry, discovered schema registry, and custom schema registry.When ...
Read more >
Amazon EventBridge schema registries
AWS event schema registry – The built-in schemas. Discovered schema registry – The schemas discovered by Schema discovery. You can create custom registries...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found