Refactor GetBookmarkStatusFunction response logic #88
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We are currently observing numerous
404 NotFound
responses from theGetBookmarkStatusFunction
in the client Application Insights. The current logic generates two types of responses:In both cases, the
error
property is set tofalse
, which indicates a successful operation. The only distinction is thebookmarkStatus
property and the different status codes (200 vs. 404). However, the front-end app relies on thebookmarkStatus
property alone to display different icons, while Application Insights on the front end logs any 400-500 status codes as failures automatically.Suggested Improvement
To streamline this logic, I’ve updated the response to a single format which makes it generic, returning a 200 OK status code in all cases. This change removes the 404 response for the "not found" case, as it conflicts with the
error = false
indicator and avoids marking these responses as failures.Now, the response is a unified JSON object that differs only by the
bookmarkStatus
property, with a consistent 200 OK status code. This will ensure Application Insights does not log these responses as failures, aligning the backend response with frontend expectations.Logging: The conditional
_logger.LogInformation
also logs when no bookmarks are found in back-end, making it easier to track missing bookmarks if needed.Application Insights
Figure: The same function for different rules and users are logged as failures, in case it shouldn't be failure