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

default_listing BrowseTemplate causing 500 response #55

Open
BrianFanning opened this issue Feb 1, 2022 · 2 comments
Open

default_listing BrowseTemplate causing 500 response #55

BrianFanning opened this issue Feb 1, 2022 · 2 comments

Comments

@BrianFanning
Copy link
Contributor

This was mentioned in issue #50, but the issue was closed by the reporter. I'm having the same issue. If you are using the default BrowseTemplate, a 500 error is returned to the user. Error logs in Caddy:

{
	"level": "error",
	"ts": 1643739892.6739354,
	"logger": "http.log.error",
	"msg": "template: default_listing:5:26: executing \"default_listing\" at <.PageObj>: can't evaluate field PageObj in type caddys3proxy.PageObj",
	"request": {
		"remote_addr": "10.113.133.2:46012",
		"proto": "HTTP/1.1",
		"method": "GET",
		"host": "s3proxy.redacted",
		"uri": "/?max=20",
		"headers": {
			"X-Request-Id": ["913cd8227b352f76365baa7c2c255f"],
			"X-Real-Ip": ["10.167.1.129"],
			"X-Forwarded-Host": ["s3proxy.redacted"],
			"User-Agent": ["curl/7.80.0"],
			"Content-Type": ["text/html"],
			"X-Forwarded-For": ["10.17.1.19"],
			"X-Forwarded-Port": ["80"],
			"X-Forwarded-Proto": ["http"],
			"X-Scheme": ["http"],
			"Accept": ["*/*"]
		}
	},
	"duration": 1.04688346,
	"status": 500,
	"err_id": "eqh8tru7r",
	"err_trace": "caddy-s3-proxy.convertToCaddyError (errors.go:118)"
}
@porkcharsui
Copy link

@BrianFanning I reproduced the exact error you reported while attempting to use the browse feature to list an AWS S3 bucket. I noticed your PR #53, however when I built your branch for my s3caddy plugin and retried the request I was still unable to see the browse feature working.

And still see: http.log.error template: default_listing:5:26: executing "default_listing" at <.PageObj>: can't evaluate field PageObj in type caddys3proxy.PageObj

Were you able to get this working on your builds?

@etsxxx
Copy link

etsxxx commented Aug 22, 2022

Thank you for the great implementation.

I think this is a bug in the default template. The following part seems to be wrong.

{{- range .PageObj }}

The correct is: .PageObj -> .Items

I built @BrianFanning 's branch.
And I wrote following template file and load it, browse feature works.

<!DOCTYPE html>
<html>
        <body>
                <ul>
                {{- range .Items }}
                <li>
                {{- if .IsDir}}
                <a href="{{html .Url}}">{{html .Name}}</a>
                {{- else}}
                <a href="{{html .Url}}">{{html .Name}}</a> Size: {{html .Size}} Last Modified: {{html .LastModified}}
                {{- end}}
                </li>
                {{- end }}
                </ul>
		<p>number of items: {{ .Count }}</p>
		{{- if .MoreLink }}
		<a href="{{ html .MoreLink }}">more...</a>
		{{- end }}
        </body>
</html>

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

3 participants