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

Improve development/test env error messages for Stitches #114

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zorab47
Copy link
Contributor

@zorab47 zorab47 commented Nov 9, 2023

Problem

The current error message isn't helpful for developers during local development. It is always a confusing experience when the following is displayed unless you're familiar with Stitches:

Screen Shot 2023-11-09 at 17 28 07

Solution

Provide a helpful hint in the Rails development and test environments pointing to missing headers or mismatched allowlist_regex.

Unauthorized - no authorization header (Development/Test Env Hint: Blocked by stitches; confirm your authorization header is set OR check the `allowlist_regex` config for this path)

message = "no authorization header"

if Rails.env.test? || Rails.env.development?
message += "(Development/Test Env Hint: Stitches issue; confirm your API key header is set OR check the `allowlist_regex` for this path)"
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 also considered including the regex for reference. 🤔

@zorab47 zorab47 marked this pull request as ready for review November 9, 2023 23:31
@zorab47 zorab47 force-pushed the improve-stitches-unauthorized-message-for-dev-test-envs branch from eb7da01 to 56086eb Compare November 9, 2023 23:31
lib/stitches/api_key.rb Outdated Show resolved Hide resolved
@zorab47 zorab47 force-pushed the improve-stitches-unauthorized-message-for-dev-test-envs branch from 56086eb to 85fc6f2 Compare November 9, 2023 23:34
Copy link

@linux2647 linux2647 left a comment

Choose a reason for hiding this comment

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

🏆

Copy link
Contributor

@ebarendt ebarendt 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 and definitely more helpful

The current error message isn't helpful for development, so provide
a helpful hint in the Rails development and test environments.
@zorab47 zorab47 force-pushed the improve-stitches-unauthorized-message-for-dev-test-envs branch from 85fc6f2 to 773dccd Compare November 9, 2023 23:44
Copy link

@AddieEli AddieEli left a comment

Choose a reason for hiding this comment

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

this is realllllllly nice, thanks! and it would be nice to see the regex, it may save you from a binding.pry 🤷‍♀️ but either way, amaze. thank you!

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.

None yet

4 participants