-
Notifications
You must be signed in to change notification settings - Fork 6
fix(sdk): log RESOURCE_NOT_FOUND errors at debug level #30
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
base: main
Are you sure you want to change the base?
fix(sdk): log RESOURCE_NOT_FOUND errors at debug level #30
Conversation
ACP lacks a stat API, so agents check file existence by attempting to read. When writing a new file, this returns -32002 which is expected behavior, not an error. Log these at debug level to reduce noise. Also adds ErrorCode constant for self-documenting error code checks.
| // RESOURCE_NOT_FOUND is expected when checking file existence | ||
| // before write, since ACP has no stat API | ||
| if (error.code === ErrorCode.RESOURCE_NOT_FOUND) { | ||
| console.debug(context, message, error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this matter though? stdout is for ACP messages, and all logs need to go out on stderr (most agents end up pointing console.debug to console.error for this reason)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so gemini-cli reads before writes at the moment (to create a diff for the permission approval), so there's a bit of spam every time it tries to create a new file... I'm not really used to seeing scary things for common issues.. any ideas on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or are you saying that console.debug will always be written to stderr anyway.. basically I'm open to options I may not have the best solution in mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes for gemini cli + claude code all console logs are routed to stderr, otherwise they would be sent over stdout to the ACP client
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I meant to ask if there is a better way to deprioritize this type of log message.. assuming any log has to go to stderr or otherwise not stdout. Or if we should close this PR and just accept that a resource not found due to "check before write" will have this effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean... it is a good question... these messages are kind of already in the stdin feed.
I could see this as something we filter out. But I guess I can also see cases where this error is helpful for other reasons..
It is also on my todo list somewhere to add a stat api to ACP because it would be useful in more than just this case :D
ACP lacks a stat API, so agents check file existence by attempting to read. When writing a new file, this returns -32002 which is expected behavior, not an error. Log these at debug level to reduce noise.
Also adds ErrorCode constant for self-documenting error code checks.