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(availability): PPT-1629 return 404 when tenant not found #334

Merged
merged 6 commits into from
Dec 2, 2024

Conversation

naqvis
Copy link
Contributor

@naqvis naqvis commented Nov 13, 2024

No description provided.

@naqvis naqvis requested a review from chillfox November 13, 2024 07:12
@github-actions github-actions bot added the type: bug something isn't working label Nov 13, 2024
@naqvis naqvis requested a review from stakach November 20, 2024 05:56
@github-actions github-actions bot added type: bug something isn't working and removed type: bug something isn't working labels Nov 29, 2024
@github-actions github-actions bot added type: bug something isn't working and removed type: bug something isn't working labels Nov 29, 2024
@stakach stakach self-requested a review November 29, 2024 06:05
Copy link
Member

@stakach stakach 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 should just add a before_filter that calls this function:

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:

@[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

@naqvis
Copy link
Contributor Author

naqvis commented Dec 1, 2024

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?

@stakach
Copy link
Member

stakach commented Dec 1, 2024

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:
return 404 when tenant not found
That should be
return 404 when no matching calendars found

I think there are two issues being conflated

  1. if a tenant isn't configured then we should be raising something like a Not Implemented - a 501 maybe? We should consult with @MrYuion to ensure this wouldn't disrupt the frontend
  2. we should raise a 204 No Content maybe to indicate that no matching calendars were found with a valid empty response object?

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
@jeremyw24 do you agree?

@github-actions github-actions bot added type: bug something isn't working and removed type: bug something isn't working labels Dec 2, 2024
@github-actions github-actions bot added type: bug something isn't working and removed type: bug something isn't working labels Dec 2, 2024
@github-actions github-actions bot added type: bug something isn't working and removed type: bug something isn't working labels Dec 2, 2024
Copy link
Member

@stakach stakach left a comment

Choose a reason for hiding this comment

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

LGTM

@stakach stakach merged commit 44dcd56 into master Dec 2, 2024
11 checks passed
@stakach stakach deleted the PPT-1629 branch December 2, 2024 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants