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

fix: Don't show Billings on settings navbar when self-hosted #1912

Merged
merged 4 commits into from
Feb 28, 2025

Conversation

tonyvince
Copy link
Contributor

close #1911

@tonyvince
Copy link
Contributor Author

Can't reproduce test failures locally.

@tonyvince
Copy link
Contributor Author

tests fail when running with seed bin/rails test:system --seed 19659

Copy link
Collaborator

@zachgoll zachgoll left a comment

Choose a reason for hiding this comment

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

@tonyvince thanks for the fix here, but I think instead of trying to fix this error, we should never be experiencing it in the first place.

I think in self hosted mode, we should remove the "Billing" page entirely from the application and disable all Stripe / Billing related code when SELF_HOSTED=true

@tonyvince tonyvince changed the title fix: Fix app crash when managing subscription with invalid stripe key fix: Don't show Billings on settings navbar when self-hosted Feb 27, 2025
@tonyvince
Copy link
Contributor Author

@zachgoll changed implementation

Copy link
Collaborator

@zachgoll zachgoll left a comment

Choose a reason for hiding this comment

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

I think we'll need to add condition: :self_hosted? in our settings helper too:

SETTINGS_ORDER = [
{ name: I18n.t("settings.settings_nav.profile_label"), path: :settings_profile_path },
{ name: I18n.t("settings.settings_nav.preferences_label"), path: :settings_preferences_path },
{ name: I18n.t("settings.settings_nav.security_label"), path: :settings_security_path },
{ name: I18n.t("settings.settings_nav.self_hosting_label"), path: :settings_hosting_path, condition: :self_hosted? },
{ name: I18n.t("settings.settings_nav.billing_label"), path: :settings_billing_path },
{ name: I18n.t("settings.settings_nav.accounts_label"), path: :accounts_path },
{ name: I18n.t("settings.settings_nav.imports_label"), path: :imports_path },
{ name: I18n.t("settings.settings_nav.tags_label"), path: :tags_path },
{ name: I18n.t("settings.settings_nav.categories_label"), path: :categories_path },
{ name: I18n.t("settings.settings_nav.merchants_label"), path: :merchants_path },
{ name: I18n.t("settings.settings_nav.whats_new_label"), path: :changelog_path },
{ name: I18n.t("settings.settings_nav.feedback_label"), path: :feedback_path }
]

@tonyvince tonyvince requested a review from zachgoll February 28, 2025 08:59
Copy link
Collaborator

@zachgoll zachgoll left a comment

Choose a reason for hiding this comment

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

Other than the Stripe error handling, looks good!

before_action :redirect_to_root_if_self_hosted
rescue_from Stripe::AuthenticationError do
redirect_to settings_billing_path, alert: "Invalid Stripe secret key."
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the reasoning behind this rescue_from block? My preference would be to avoid any "swallowing" of errors silently as we'd want to hit an error in our hosted version if something is wrong with Stripe.

If we're getting an error like this, I think that indicates that there is a problem upstream somewhere in the configuration for self hosted instances that we need to address to ensure we aren't calling Stripe-related code on self hosted apps at all.

@tonyvince tonyvince requested a review from zachgoll February 28, 2025 14:20
Copy link
Collaborator

@zachgoll zachgoll left a comment

Choose a reason for hiding this comment

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

Looks good!

@zachgoll zachgoll merged commit 624faa1 into maybe-finance:main Feb 28, 2025
5 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.

Bug: Error when trying to subscribe with incorrect stripe secret key
2 participants