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

api: return 500 instead of 404 in case of non-existing items #2582

Merged
merged 1 commit into from
Oct 27, 2023

Conversation

aler9
Copy link
Member

@aler9 aler9 commented Oct 27, 2023

This is needed to differentiate between calls to non-existent andpoints and calls to valid endpoints, but with an ID pointing to a non-existing item, and to return JSON in the latter case.

This is needed to differentiate between calls to non-existent andpoints
and calls to valid endpoints, but with an ID pointing to a non-existing
item.
@codecov
Copy link

codecov bot commented Oct 27, 2023

Codecov Report

Merging #2582 (ccc70a1) into main (6af27fd) will increase coverage by 0.21%.
The diff coverage is 96.42%.

@@            Coverage Diff             @@
##             main    #2582      +/-   ##
==========================================
+ Coverage   59.60%   59.81%   +0.21%     
==========================================
  Files         145      145              
  Lines       15528    15520       -8     
==========================================
+ Hits         9255     9284      +29     
+ Misses       5620     5593      -27     
+ Partials      653      643      -10     
Files Coverage Δ
internal/core/hls_manager.go 94.56% <100.00%> (+1.08%) ⬆️
internal/core/path_manager.go 89.92% <100.00%> (ø)
internal/core/rtmp_server.go 88.58% <100.00%> (+1.63%) ⬆️
internal/core/rtsp_server.go 87.01% <100.00%> (+1.05%) ⬆️
internal/core/srt_server.go 89.83% <100.00%> (+1.69%) ⬆️
internal/core/webrtc_manager.go 64.64% <100.00%> (+0.95%) ⬆️
internal/core/api.go 66.20% <94.11%> (+3.19%) ⬆️

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@aler9 aler9 merged commit 07ff79f into main Oct 27, 2023
8 checks passed
@aler9 aler9 deleted the feature/api-500 branch October 27, 2023 18:23
@tbnguyen1407
Copy link

tbnguyen1407 commented Oct 30, 2023

Hello, just a suggestion to intead use

  • 501: for unknown/unmapped route (where we are not aware of the requested resource)
  • 404: for non-existent resources (where we are aware of the resource but cannot find it)

Since 404 is very common for standard CRUD APIs, using 500 code for it seems a bit weird and we must deserialize the body and check for a hardcoded string to know if it is not found or other error.

I also found the code is inconsistent for DELETE/PATCH, which currently return 400 for non-existent path.

@aler9
Copy link
Member Author

aler9 commented Jan 18, 2024

@tbnguyen1407 i fixed it in #2920

Copy link
Contributor

This issue is mentioned in release v1.5.0 🚀
Check out the entire changelog by clicking here

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

2 participants