Skip to content
This repository was archived by the owner on Jul 22, 2020. It is now read-only.

Comments

Use decoded URI path partial for file paths#225

Merged
prymitive merged 2 commits intomasterfrom
file-uri-fix
Jan 27, 2018
Merged

Use decoded URI path partial for file paths#225
prymitive merged 2 commits intomasterfrom
file-uri-fix

Conversation

@prymitive
Copy link
Contributor

URI passed to the file:// schema handler might contain query args (?limit=10), when we use a relative path we correctly return u.Path, but for absolute paths full uri with stripped schema part was used. Absolute path should be assembled only current dir and path u.Path

This was only affecting Alertmanager 0.4.x that uses pagination and requires ?limit=N query args:

ERRO[0000] [default] file://internal/mock/0.4.2/api/v1/silences?limit=2147483647 request failed: open Go/src/github.com/cloudflare/unsee/internal/mock/0.4.2/api/v1/silences?limit=2147483647: no such file or directory

with this PR reading works correctly:

INFO[0000] Reading file '/Users/lukasz/Go/src/github.com/cloudflare/unsee/internal/mock/0.4.2/api/v1/silences'
INFO[0000] [default] Got 3 silences(s) in 314.053µs

@prymitive prymitive added the bug label Jan 27, 2018
@prymitive prymitive added this to the v0.9 milestone Jan 27, 2018
For absolute paths we correctly return full decoded path, but for relative paths we can't simply strip file:// prefix as it might leave query args in place. Build absolute path by joining working dir + hostname part + path part.
Add an extra test case for coverage.
@prymitive prymitive merged commit 78cbd10 into master Jan 27, 2018
@prymitive prymitive deleted the file-uri-fix branch January 27, 2018 23:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants