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

Error messages due to invalid logging optimization #893

Open
em-al-wi opened this issue Jan 27, 2025 · 0 comments
Open

Error messages due to invalid logging optimization #893

em-al-wi opened this issue Jan 27, 2025 · 0 comments
Labels
bug Something isn't working triage

Comments

@em-al-wi
Copy link

What Happened?

Since version 1.8.4 error messages in the log appear whenever a service response is not a JSON document or the JSON is longer then 1,000 characters.

ERROR SyntaxError: Unterminated string in JSON at position 1003 at JSON.parse (<anonymous>) at Fi (file:///usr/src/app/node_modules/.pnpm/@[email protected]/node_modules/@portkey-ai/gateway/build/start-server.js:2:260672) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

What Should Have Happened?

No error messages.

Relevant Code Snippet

The commit introducing the error: cf25af7

The change does not take into account that a response is not always json. And if it is json but longer than 1,000 characters, it truncates the json and tries to parse it.

src/middlewares/log/index.ts:
JSON.parse(responseString.substring(0, maxLength) + '...')

Your Twitter/LinkedIn

No response

@em-al-wi em-al-wi added the bug Something isn't working label Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

No branches or pull requests

1 participant