Skip to content

backend validation accept/deny#119

Open
swarkewalia wants to merge 7 commits intomainfrom
sk/SSF-151-restrict-actions
Open

backend validation accept/deny#119
swarkewalia wants to merge 7 commits intomainfrom
sk/SSF-151-restrict-actions

Conversation

@swarkewalia
Copy link

@swarkewalia swarkewalia commented Mar 8, 2026

ℹ️ Issue

Closes

📝 Description

added backend validation to throw a BadRequestException when a user tries to approve or deny a non pending pantry or manufacturer. also found a bug with foodManufacturer missing relations so fixed that too!

✔️ Verification

tried to approve/deny a non pending pantry/manufacturer

Copy link

@Juwang110 Juwang110 left a comment

Choose a reason for hiding this comment

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

Honestly lgtm, one thing though. @sam-schu @Yurika-Kan I was going to comment to add test cases for these new bad request exceptions but it seems like approve/deny routes for both manufacturers and pantries don't have service tests. Should we add them here or is it fine?

@sam-schu
Copy link
Collaborator

sam-schu commented Mar 9, 2026

@Juwang110 We don't have manufacturers service tests at all yet, and the pantries service tests are still mocking the repository. We don't need to worry about those tests here, we will add/update them in a future ticket!

@Juwang110 Juwang110 self-requested a review March 9, 2026 15:59
Copy link

@Juwang110 Juwang110 left a comment

Choose a reason for hiding this comment

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

lgtm then!

Copy link
Collaborator

@sam-schu sam-schu left a comment

Choose a reason for hiding this comment

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

  1. ConflictException might be better here since the client request is perfectly fine on its own, it's just that it conflicts with the current state of the pantry/manufacturer
  2. Could you clarify why it was a bug not having the foodManufacturerRepresentative relation?

@swarkewalia
Copy link
Author

  1. ConflictException might be better here since the client request is perfectly fine on its own, it's just that it conflicts with the current state of the pantry/manufacturer
  2. Could you clarify why it was a bug not having the foodManufacturerRepresentative relation?

updated the exception! also thought it was a bug since the relation would be loaded as undefined, so when approve/deny methods try to access info about the foodManufacturer's user (foodManufacturerRepresentative) they would throw a 'cannot read properties of undefined error'.

@maxn990 maxn990 requested a review from sam-schu March 12, 2026 14:10
Copy link
Collaborator

@sam-schu sam-schu left a comment

Choose a reason for hiding this comment

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

Oh I see, thanks for catching that!

  • Just a note: normally I would not suggest updating the findOne service function to fix that bug - that function is used by the GET /api/manufacturers/:foodManufacturerId endpoint, so updating that function could cause the endpoint to return an extra relation that isn't needed. But in this case, that endpoint doesn't look to be called in the frontend, and when we do use that endpoint to view manufacturer applications later, we will need the representative info, so updating it is fine in this case!
  • It looks like the bug is still happening because the approve function is still using the repo's findOne function, not the service's - can we change that?

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.

3 participants