[fix]: Null Handling for getStockById
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
Research direction
Start in OperationController at the getStockById endpoint and inspect how it calls operationService.getStockById. Make the endpoint return HTTP 404 when no stock is found and verify the behavior for an existing and a nonexistent ID with Postman or cURL.
Written by the indexing model from the issue text.
Description
Description
- Detailed Description:
The methodgetStockByIdinOperationControllerreturnsnullwhen no stock is found, which is not an informative response for API consumers. A proper HTTP 404 Not Found should be returned. - How to Solve:
- Use ResponseEntity:
Modify the method to return aResponseEntityso that you can control the HTTP status. - Check for Null:
If the stock isnull, return a 404 response:@GetMapping("/{id}") public ResponseEntity<Stock> getStockById(@PathVariable Long id) { Stock stock = operationService.getStockById(id); return (stock != null) ? ResponseEntity.ok(stock) : ResponseEntity.notFound().build(); } - Test the Endpoint:
Use tools like Postman or cURL to ensure that a non-existent stock ID returns a 404 status.
- Use ResponseEntity:
- Dominant language
- TypeScript
- Stars
- 1
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from iiitl/Stoxs
-
docker feature medium
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
-
feature hard java spring-boot
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
hard java spring-boot test
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
fix java medium spring-boot
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
feature java medium spring-boot
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100