-
Notifications
You must be signed in to change notification settings - Fork 0
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(availability): PPT-1629 return 404 when tenant not found #334
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should just add a before_filter that calls this function:
staff-api/src/controllers/utilities/multi_tenant.cr
Lines 33 to 38 in 5b325ad
def current_tenant : Tenant | |
determine_tenant_from_domain unless @tenant | |
the_tenant = @tenant | |
raise Error::NotImplemented.new("domain does not have a tenant configured") unless the_tenant | |
the_tenant | |
end |
Then this would respond appropriately for every route in the controller
example before_filter:
staff-api/src/controllers/bookings.cr
Lines 36 to 47 in 6a24c92
@[AC::Route::Filter(:before_action, only: [:index, :add_attendee, :booked])] | |
private def set_tenant_from_domain | |
if auth_token_present? | |
check_jwt_scope | |
determine_tenant_from_domain | |
else | |
domain = request.hostname.as?(String) | |
raise Error::BadRequest.new("missing domain header") unless domain | |
@tenant = Tenant.find_by?(domain: domain) | |
raise Error::NotFound.new("could not find tenant with domain: #{domain}") unless tenant | |
end | |
end |
confused here on the approach you suggested and approach ode is making decision on . code is returning 404 only if matching calendars are empty, but your suggestion is to retrieve tenant from PG. Question would be how does this PG stored tenant relates to Office Calendars returned response being empty? |
I was confused by the title of this issue: I think there are two issues being conflated
As no candidate calendars is a valid thing that can happen but we want to differentiate that from graph api errors etc so a 404 is not correct and probably would confuse things further |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.