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

Always print warning on blocked outbound HTTP #1833

Merged
merged 2 commits into from
Oct 3, 2023

Conversation

itowlson
Copy link
Contributor

@itowlson itowlson commented Oct 2, 2023

Fixes #1090.

With the proposed text, it looks like this:

image

Get painting those bikesheds.

(Note that the host component doesn't know which component it's attached to, so we can't provide a component ID without more work (heaven forfend.)

Signed-off-by: itowlson <ivan.towlson@fermyon.com>
@@ -53,6 +53,9 @@ impl outbound_http::Host for OutboundHttp {
.map_err(|_| HttpError::RuntimeError)?
{
tracing::log::info!("Destination not allowed: {}", req.uri);
terminal::warn!("A component tried to make a HTTP request to '{}'.", req.uri);
eprintln!("The component was configured not to allow requests to this host.");
eprintln!("To allow requests, add the host to `allowed_http_posts`.");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
eprintln!("To allow requests, add the host to `allowed_http_posts`.");
eprintln!("To allow requests, add the host name to the `allowed_http_posts` key/value pair in the component section of spin.toml.");

Copy link
Contributor

Choose a reason for hiding this comment

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

Could we perhaps even include a link to the developer hub page about this? Something like

See https://developer.fermyon.com/spin/manifest-reference#the-component-tables for more information.

Copy link
Collaborator

Choose a reason for hiding this comment

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

🚲🏚️

To allow requests, add e.g. `allowed_http_hosts = ["<host from actual request>"]`
to the the component's section of spin.toml.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did wonder to what extent to make this a "explain what is happening" vs "write exhaustive documentation on how to fix it." E.g. I thought about warning them to restart after making the change, but was wary of turning it into a wall of text that the eyes just slid off. It may be too much in that direction already; I'd have preferred to keep it to 1 or 2 lines.

Copy link
Member

@mikkelhegn mikkelhegn left a comment

Choose a reason for hiding this comment

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

LGTM 👍🏻

Copy link
Contributor

@tschneidereit tschneidereit left a comment

Choose a reason for hiding this comment

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

Looks great, thank you! I think adding either Mikkel's suggestion or something like mine (or a combination of both) would be good, but otherwise 🚢 it.

@@ -53,6 +53,9 @@ impl outbound_http::Host for OutboundHttp {
.map_err(|_| HttpError::RuntimeError)?
{
tracing::log::info!("Destination not allowed: {}", req.uri);
terminal::warn!("A component tried to make a HTTP request to '{}'.", req.uri);
eprintln!("The component was configured not to allow requests to this host.");
eprintln!("To allow requests, add the host to `allowed_http_posts`.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we perhaps even include a link to the developer hub page about this? Something like

See https://developer.fermyon.com/spin/manifest-reference#the-component-tables for more information.

@itowlson
Copy link
Contributor Author

itowlson commented Oct 3, 2023

Based on feedback and angst I'm trying a new message:

image

I sent this as a separate commit so it's easy to back out if people hate this more than the previous one.

@lann
Copy link
Collaborator

lann commented Oct 3, 2023

to the component manifest.

I'm not sure that people will know what this means. Reference spin.toml in some form?

Copy link
Collaborator

@lann lann left a comment

Choose a reason for hiding this comment

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

Specific wording aside, lgtm

@itowlson
Copy link
Contributor Author

itowlson commented Oct 3, 2023

I avoided mentioning spin.toml because we don't know where the app came from. I was thinking I should check if it came from a local manifest and not print the message at all if not, because if it comes from OCI then they can't edit it anyway. It wasn't obvious to me how to determine if a LockedApp origin was OCI or file but I guess I could punt in the ol' "looks like an OCI reference" heuristic.

@lann
Copy link
Collaborator

lann commented Oct 3, 2023

Ah yeah. Maybe something like "manifest component section" then? We have been discussing having a separate "component manifest" thing...

@itowlson
Copy link
Contributor Author

itowlson commented Oct 3, 2023

SOLD

Signed-off-by: itowlson <ivan.towlson@fermyon.com>
@itowlson itowlson merged commit b4c54ca into fermyon:main Oct 3, 2023
9 checks passed
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

Successfully merging this pull request may close these issues.

Better inner loop experience for blocked HTTP hosts
4 participants