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

Harness Compilation error page has status 200 OK #198

Open
r32rf opened this issue Oct 9, 2020 · 0 comments
Open

Harness Compilation error page has status 200 OK #198

r32rf opened this issue Oct 9, 2020 · 0 comments

Comments

@r32rf
Copy link

r32rf commented Oct 9, 2020

When Harness responds with a compilation error, it generates the page with 200 OK.
https://github.com/revel/cmd/blob/master/harness/harness.go#L137

atomic.CompareAndSwapInt32(&lastRequestHadError, 0, 1)
h.renderError(w, r, err)
return

It would probably be best to call w.WriteHeader(http.StatusInternalServerError).

This issue affected me in a AJAX handler that triggered the success callback on a compilation error with the HTML as a string rather than the decoded JSON object I was expecting.

Furthermore, it would be nicer if the error response also respected the Accept HTTP header. For example, if Accept equals "application/json":

{
    "Error": "Go Compilation Error", // Equal to the title of the html page.
    "Message": "The Go code %s does not compile: %s", // Equal to the content of .header p
    "File":  {
        "File": "%s (around line %d)", // Equal to .source h2
        "Line": "%s", // Equal to the highlighted code block rendered in .source
     }
}
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

No branches or pull requests

1 participant