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 · 3 comments
Open

Error messages due to invalid logging optimization #893

em-al-wi opened this issue Jan 27, 2025 · 3 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/@portkey-ai+gateway@1.9.3/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
@narengogi
Copy link
Collaborator

@em-al-wi got it, will remove the check,
do you want to take this up?

@em-al-wi
Copy link
Author

@narengogi It would be greatly appreciated if you could remove the check. This also becomes messy when using guardrails, as the response is usually more than 1,000 characters in length then.

@urbanonymous
Copy link

urbanonymous commented Mar 3, 2025

Happening here as well. Also getting Unterminated fractional number in JSON at position 1001.

portkey v1.8.3 (can't update because other bug that you have breaks the portkey server)

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

3 participants