Skip to content

CBG-5425 avoid writing zero sized files into sgcollect#8319

Open
torcolvin wants to merge 1 commit into
mainfrom
CBG-5425
Open

CBG-5425 avoid writing zero sized files into sgcollect#8319
torcolvin wants to merge 1 commit into
mainfrom
CBG-5425

Conversation

@torcolvin

Copy link
Copy Markdown
Collaborator

CBG-5425 avoid writing zero sized files into sgcollect

When authentication fails some of the output for /debug/_pprof ends up 0 sized. These files aren't useful in sgcollect, and we know why a task failed in sync_gateway.log. I find this very confusing when looking at these files.

Pre-review checklist

  • Removed debug logging (fmt.Print, log.Print, ...)
  • Logging sensitive data? Make sure it's tagged (e.g. base.UD(docID), base.MD(dbName))
  • Updated relevant information in the API specifications (such as endpoint descriptions, schemas, ...) in docs/api

Copilot AI review requested due to automatic review settings June 1, 2026 16:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an early-return in PythonTask.execute so that when the task callable returns a falsy value (e.g. b"" from a failed curl/auth-denied response in sgcollect's /debug/_pprof capture), no bytes are written to the destination file. Two new tests cover the empty-result path for both add_file_task and make_curl_task.

Changes:

  • PythonTask.execute returns 0 immediately when self.callable() produces a falsy result, avoiding the subsequent result.encode() / fp.write(result) calls.
  • Adds test_add_file_task_zero_size and test_make_curl_task_zero_size exercising the empty-result path.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tools/tasks.py Skip writing/encoding when a PythonTask callable returns a falsy result.
tools-tests/tasks_test.py New tests for the zero-size result handling in add_file_task and make_curl_task.

Comment thread tools/tasks.py
Comment on lines +232 to +233
if not result:
return 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants