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

[FEAT]: should 304 conditional requests be logged as errors? #725

Open
1 task done
jeffwilcox opened this issue Oct 30, 2024 · 6 comments
Open
1 task done

[FEAT]: should 304 conditional requests be logged as errors? #725

jeffwilcox opened this issue Oct 30, 2024 · 6 comments
Labels
Type: Feature New feature or request

Comments

@jeffwilcox
Copy link

jeffwilcox commented Oct 30, 2024

Describe the need

Not sure if this is a request to "change the default behavior" or "allow some magical flags to customize"...

We make use of conditional requests a lot. We've had to patch the standard Octokit opinionated plugin choices with a version where we treat a 304 error.status as informational instead of an error - our server logs were full of all the conditional requests that "successfully" returned 304s.

Not sure if this is something that's come up before, but would love to know how common it is that others do not want to see endless log spew such as this...

GET /repos/contosoenterprise/my-test-repo - 304 with id F178:35CFAD:10ED6DE5:100C9A83:6722BC7D in 243ms

Just a comment.

SDK Version

N/A

API Version

N/A

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@jeffwilcox jeffwilcox added Status: Triage This is being looked at and prioritized Type: Feature New feature or request labels Oct 30, 2024
Copy link

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@wolfy1339
Copy link
Member

there is no error level logging in this module, it is either log level debug or info

@jeffwilcox
Copy link
Author

I am specifically looking at this line:

https://github.com/octokit/plugin-request-log.js/blob/268c62891d89b2d4b094bf6c7d179b88baa84842/src/index.ts#L30

octokit.log.error(
          `${requestOptions.method} ${path} - ${error.status} with id ${requestId} in ${
            Date.now() - start
          }ms`,
        );

This is what we've overridden in our own Octokit scripts to log this as info and not error if error.status === 304.

@jeffwilcox jeffwilcox changed the title [FEAT]: should 304 conditional requests be treated as errors? [FEAT]: should 304 conditional requests be logged as errors? Oct 31, 2024
@wolfy1339
Copy link
Member

The root of this issue is not in this module but rather in @octokit/request

if (status === 304) {
octokitResponse.data = await getResponseData(fetchResponse);
throw new RequestError("Not modified", status, {
response: octokitResponse,
request: requestOptions,
});
}

We throw an error specifically if the status is a 304

All this plugin does is catch errors from requests and logs them with the error level

@jeffwilcox
Copy link
Author

OK, fair. We'll just keep patching in our world. Thanks!

@jeffwilcox jeffwilcox closed this as not planned Won't fix, can't repro, duplicate, stale Oct 31, 2024
@wolfy1339 wolfy1339 transferred this issue from octokit/plugin-request-log.js Oct 31, 2024
@wolfy1339 wolfy1339 reopened this Oct 31, 2024

This comment was marked as outdated.

@wolfy1339 wolfy1339 removed the Status: Triage This is being looked at and prioritized label Oct 31, 2024
@wolfy1339 wolfy1339 moved this from ✅ Done to 🔥 Backlog in 🧰 Octokit Active Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature New feature or request
Projects
Status: 🔥 Backlog
Development

No branches or pull requests

2 participants