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

Fix lack of error on file site export, improve lack of ADMIN_PASSWD error message #1734

Merged
merged 2 commits into from
Jan 28, 2024

Conversation

paskal
Copy link
Collaborator

@paskal paskal commented Jan 28, 2024

Previously, status 200 was set for file export, which is used for backup, which resulted in an inability to set an error status code in case of a problem with file generation.

After this change, status code 200 would be written automatically by Go before we start writing the response's body.

Also, add meaningful error for lack of auth on import, remap and backup.

Previously, the error printed was just the following:

error response "401 Unauthorized", Unauthorized"

New error:

error response "401 Unauthorized", ensure you have set ADMIN_PASSWD and provided it to the command you're running: Unauthorized

Copy link

github-actions bot commented Jan 28, 2024

Pull Request Test Coverage Report for Build 7686355908

  • 0 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.1%) to 84.878%

Files with Coverage Reduction New Missed Lines %
backend/app/rest/api/rss.go 1 83.33%
Totals Coverage Status
Change from base Build 7596391691: 0.1%
Covered Lines: 5972
Relevant Lines: 7036

💛 - Coveralls

@@ -56,7 +56,6 @@ func (s *rss) postCommentsCtrl(w http.ResponseWriter, r *http.Request) {

w.Header().Set("Content-Type", "application/xml; charset=utf-8")
w.WriteHeader(http.StatusOK)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is just for consistency. I've checked all WriteHeader(http.StatusOK) for the bug's presence, and that is the only place in the rss.go file with that extra newline, while two others don't.

Previously, status 200 was set for file export, which is used
for backup, which resulted in an inability to set an error status code
in case of a problem with file generation.

After this change, status code 200 would be written automatically by Go
before we start writing the response's body.
@paskal paskal force-pushed the paskal/fix_backup_error branch 2 times, most recently from 714182b to 6d6c86f Compare January 28, 2024 13:56
@paskal paskal changed the title Fix lack of error on file site export Fix lack of error on file site export, improve lack of ADMIN_PASSWD error message Jan 28, 2024
Previously, the error printed was just the following:

error response "401 Unauthorized", Unauthorized"

New error:

error response "401 Unauthorized", ensure you have set ADMIN_PASSWD
and provided it to the command you're running: Unauthorized
@umputun umputun merged commit 0050c65 into master Jan 28, 2024
3 checks passed
@umputun umputun deleted the paskal/fix_backup_error branch January 28, 2024 18:16
@paskal paskal added this to the v1.13.0 milestone Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants