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: Failure while trying to convert JSON to protobuf with Schemaverse #1387

Open
1 task done
yanivbh1 opened this issue Nov 3, 2023 · 0 comments
Open
1 task done
Assignees
Labels
bug Something isn't working

Comments

@yanivbh1
Copy link
Contributor

yanivbh1 commented Nov 3, 2023

Describe the bug

Hey,
I have the following events coming in through API calls in JSON

{
  items: [ { name: 'burger', quantity: 100 } ],
  email: '[email protected]',
  total: 5000
}

and this is the code that should produce them into a station:

const { memphis } = require('memphis-dev');
const { logger } = require('./loggerService')
const MEMPHIS_HOST = process.env.MEMPHIS_HOST;
const MEMPHIS_USERNAME = process.env.MEMPHIS_USERNAME;
const MEMPHIS_PASSWORD = process.env.MEMPHIS_PASSWORD;
const MEMPHIS_ACCOUNTID = process.env.MEMPHIS_ACCOUNTID;
let orders_service_producer = null;

const memphisConnect = async () => {
    try {
        logger.info(`Memphis - trying to connect`)
        await memphis.connect({
            host: MEMPHIS_HOST,
            username: MEMPHIS_USERNAME,
            password: MEMPHIS_PASSWORD,
            accountId: MEMPHIS_ACCOUNTID
        });
        logger.info(`Memphis - connection established`)

        orders_service_producer = await memphis.producer({
            stationName: "orders",
            producerName: "orders_service",
        });
        logger.info(`orders_service producer created`)
    } catch(ex) {
        logger.log('fatal',`Memphis - ${ex}`);
        memphis.close();
        process.exit();
    }
}

Without an enforced schema, everything works well, but when I enforce a schema, I get the following error:

03-11-2023 10:42:02 AM - info: POST /api/orders 201 89 ::1 - 17.368 ms

node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

Error: Schema validation has failed: Invalid message format, expecting protobuf
    at Producer._validateProtobufMessage (/private/tmp/onboarding-app/order-service/node_modules/memphis-dev/lib/producer.js:183:57)
    at Producer._validateMessage (/private/tmp/onboarding-app/order-service/node_modules/memphis-dev/lib/producer.js:243:33)
    at Producer.produce (/private/tmp/onboarding-app/order-service/node_modules/memphis-dev/lib/producer.js:44:38)
    at Object.publishOrderToStation (/private/tmp/onboarding-app/order-service/src/services/mqService.js:37:29)
    at placeOrder (/private/tmp/onboarding-app/order-service/src/controllers/orderController.js:19:25)
    at Layer.handle [as handle_request] (/private/tmp/onboarding-app/order-service/node_modules/express/lib/router/layer.js:95:5)
    at next (/private/tmp/onboarding-app/order-service/node_modules/express/lib/router/route.js:144:13)
    at Route.dispatch (/private/tmp/onboarding-app/order-service/node_modules/express/lib/router/route.js:114:3)
    at Layer.handle [as handle_request] (/private/tmp/onboarding-app/order-service/node_modules/express/lib/router/layer.js:95:5)
    at /private/tmp/onboarding-app/order-service/node_modules/express/lib/router/index.js:284:15

Node.js v19.4.0

Steps to reproduce

Written above

Affected services

Broker, Data, SDKs

Broker version

1.3.0-latest

Platforms

No response

If UI - Browsers

No response

Environment

No response

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@yanivbh1 yanivbh1 added the bug Something isn't working label Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants