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

Dhall does not provide a User-Agent string #881

Open
ad-si opened this issue Jan 12, 2020 · 11 comments
Open

Dhall does not provide a User-Agent string #881

ad-si opened this issue Jan 12, 2020 · 11 comments

Comments

@ad-si
Copy link
Contributor

@ad-si ad-si commented Jan 12, 2020

I just tried to load some content from the GitHub API, however they refuse to serve because the request doesn't provide a User-Agent String. Maybe we should add one?

$ echo "https://api.github.com/repos/ad-si/Tasklite/issues/1 as Text" | dhall
dhall:
Error: Access forbidden

HTTP status code: 403

URL: https://api.github.com/repos/ad-si/Tasklite/issues/1

Message:

1│ Request forbidden by administrative rules. 
Please make sure your request has a User-Agent header 
(http://developer.github.com/v3/#user-agent-required). 
Check https://developer.github.com for other possible causes.
@Gabriel439

This comment has been minimized.

Copy link
Contributor

@Gabriel439 Gabriel439 commented Jan 12, 2020

I think the main question is if we should have a standard user agent (e.g. Dhall/13.0.0) or if this should be a Haskell-specific fix? I'm guessing this should be standardized?

@ad-si

This comment has been minimized.

Copy link
Contributor Author

@ad-si ad-si commented Jan 12, 2020

if we should have a standard user agent (e.g. Dhall/13.0.0)

Sounds reasonable. I'd just fear that provider start blocking Dhall (for whatever reason). So maybe it should be user configurable (e.g. via a command line flag?)

What do you mean by "Haskell-specific fix"?
Standardized on which level?

@ari-becker

This comment has been minimized.

Copy link
Collaborator

@ari-becker ari-becker commented Jan 13, 2020

dhall <<< 'https://api.github.com/repos/ad-si/TaskLite/issues/1 using toMap { User-Agent = "placeholder" } as Text' works as expected.

If Dhall were to inject a default User-Agent header, it would need to be overrideable with the using mechanism. If it were possible, I'd argue that the standard should dictate that each implementation should define a default and inject it (e.g. Dhall-Haskell/13.0.0) but that the standard does not dictate the contents of the default, only that it must be overrideable should an expression provide a substitute.

@ad-si

This comment has been minimized.

Copy link
Contributor Author

@ad-si ad-si commented Jan 13, 2020

dhall <<< 'https://api.github.com/repos/ad-si/TaskLite/issues/1 using toMap { User-Agent = "placeholder" } as Text' works as expected.

Oh nice, didn't know this is possible! Is this documented somewhere on a higher level than on https://github.com/dhall-lang/dhall-lang/blob/master/standard/imports.md? Sounds like a useful feature people should know about.

@ari-becker

This comment has been minimized.

Copy link
Collaborator

@ari-becker ari-becker commented Jan 13, 2020

dhall <<< 'https://api.github.com/repos/ad-si/TaskLite/issues/1 using toMap { User-Agent = "placeholder" } as Text' works as expected.

Oh nice, didn't know this is possible! Is this documented somewhere on a higher level than on https://github.com/dhall-lang/dhall-lang/blob/master/standard/imports.md? Sounds like a useful feature people should know about.

https://hackage.haskell.org/package/dhall-1.29.0/docs/Dhall-Tutorial.html#g:17

The Hackage documentation is slightly out of date - using takes a Map since v9.0.0.

@ad-si

This comment has been minimized.

Copy link
Contributor Author

@ad-si ad-si commented Jan 13, 2020

Ah ok, that's why I didn't see it. I only read the general documentation. Or is it mentioned there as well?

@ari-becker

This comment has been minimized.

Copy link
Collaborator

@ari-becker ari-becker commented Jan 13, 2020

The only reference I'm finding in the general documentation is a bit of a "todo" at the beginning of https://docs.dhall-lang.org/references/Built-in-types.html

@Gabriel439

This comment has been minimized.

Copy link
Contributor

@Gabriel439 Gabriel439 commented Jan 13, 2020

Yeah, one of the oldest TODOs on my list is turning the Haskell tutorial into a language-independent tutorial

@singpolyma

This comment has been minimized.

Copy link
Collaborator

@singpolyma singpolyma commented Jan 14, 2020

I think the main question is if we should have a standard user agent (e.g. Dhall/13.0.0) or if this should be a Haskell-specific fix? I'm guessing this should be standardized?

I think a "standard" User-Agent would defeat the purpose of a user agent. It should identify the implementation, not the standard implemented.

@Profpatsch

This comment has been minimized.

Copy link
Member

@Profpatsch Profpatsch commented Jan 14, 2020

I’d just put User-Agent: Dhall and be done with it. User-Agent is a horrible misfeature in HTTP and should be purged.

@ad-si

This comment has been minimized.

Copy link
Contributor Author

@ad-si ad-si commented Jan 14, 2020

@Profpatsch Maybe that's not even a bad idea. Apparently it will get devalued anyways: https://www.zdnet.com/article/google-to-phase-out-user-agent-strings-in-chrome/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.