Skip to content

Log not found resources in bulk connection PATCH requests - #524

Open
kwy404 wants to merge 3 commits into
sony:masterfrom
kwy404:bulk-not-found-log
Open

kwy404 wants to merge 3 commits into
sony:masterfrom
kwy404:bulk-not-found-log

Conversation

@kwy404

@kwy404 kwy404 commented Sep 24, 2026 •

Copy link
Copy Markdown

A PATCH in a /bulk connection request for an unknown sender or receiver id is answered with a 404 inside the 200 OK bulk response, but nothing was logged, so it was hard to tell from the logs why an item failed. A /single request already logs the generic "Route not found".

This logs a more_info message with the id and type in the /bulk handler when an item comes back as NotFound, leaving details::handle_connection_resource_patch and the /single path unchanged.

Fixes #522

@garethsb

Copy link
Copy Markdown
Contributor

Thanks; I agree that the bulk response can be difficult to diagnose because the outer HTTP status remains as 200 OK.

I'm not sure this should be logged at warning inside handle_connection_resource_patch though. That helper is shared by single and bulk PATCHes, so a PATCH /single/... would gain this warning in addition to the existing "Route not found" log, which we try to avoid. Also, a missing resource is an ordinary 404 Not Found elsewhere in nmos-cpp; the nearby warning/error logs cover more exceptional activation-state failures.

Maybe we instead add a more_info log in the bulk handler when an item returns NotFound, including its id_type? That would fill the /bulk-specific gap without resulting in two log messages for the same issue in the /single case.

What do you think, @lo-simon ?

handle_connection_resource_patch is shared with PATCH /single, which
already logs "Route not found", so log the not found case only in the
/bulk handler, where the outer status stays 200 OK, and at more_info
like other ordinary 404 cases.
@kwy404

kwy404 commented Oct 1, 2026

Copy link
Copy Markdown
Author

Thanks @garethsb, that makes sense, I had missed that the helper is shared with /single and that it would duplicate the "Route not found" log there. In b120722 I removed the warning from handle_connection_resource_patch and instead log at more_info in the /bulk handler when an item comes back as NotFound, including its id_type ("Resource not found for sender: in bulk request"). So /single is unchanged and the /bulk case gets a single message. Happy to adjust the wording or level if @lo-simon prefers something else.

@kwy404 kwy404 changed the title Log rejected connection PATCH for a resource that is not found Log not found resources in bulk connection PATCH requests Oct 1, 2026

@lo-simon lo-simon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@garethsb and @kwy404 I think it would be better to move the logging inside the try-catch block after details::handle_connection_resource_patch. Also check status_codes::Conflict and status_codes::NotFound, since status_codes::Conflict hasn't been logged.

Move the more_info log into the try block right after handle_connection_resource_patch, since only that call returns these codes, and also log a Conflict result.
@kwy404

kwy404 commented Oct 2, 2026

Copy link
Copy Markdown
Author

Thanks @lo-simon, done in b381d3a. The log now sits inside the try block right after details::handle_connection_resource_patch, so it only covers results returned by that call (the exception handler already logs its own cases), and it logs both status_codes::NotFound ("Resource not found for <id_type> in bulk request") and status_codes::Conflict ("Resource conflict for <id_type> in bulk request"). @garethsb I kept both at more_info as you suggested, and /single is still unchanged. I could not run a full build on my machine, so I relied on the existing << id_type overload in slog.h that the other bulk logs already use; happy to tweak the wording if you prefer.

@lo-simon lo-simon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@garethsb

garethsb commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

@lo-simon Would it be odd that we'd log status_codes::Locked, BadRequest, and InternalError as warning or error within details::handle_connection_resource_patch itself which would apply to both the bulk POST handler and the single PATCH handler, but status_codes::NotFound and Conflict would now be logged as more_info during a bulk POST handler:

slog::log<slog::severities::warning>(gate, SLOG_FLF) << "Rejecting PATCH request for " << id_type << " due to a pending scheduled activation";
return details::make_connection_resource_patch_error_response(status_codes::Locked);

slog::log<slog::severities::error>(gate, SLOG_FLF) << "Rejecting PATCH request for " << id_type << " due to a pending immediate activation from the same bulk request";
return details::make_connection_resource_patch_error_response(status_codes::BadRequest);

slog::log<slog::severities::error>(gate, SLOG_FLF) << "Rejecting PATCH request for " << id_type << " due to a pending immediate activation";
return details::make_connection_resource_patch_error_response(status_codes::InternalError); // or ServiceUnavailable? probably not NotFound even if that's true after the timeout?

whereas for the single PATCH handler, "Route not found" is logged for NotFound as error as a result of make_api_finally_handler I think, but there's no logging for Conflict?

else if (status_codes::NotFound == res.status_code())
{
slog::log<slog::severities::error>(gate, SLOG_FLF) << "Route not found";
}

I'm trying to think why Conflict isn't logged in details::handle_connection_resource_patch?

@kwy404

kwy404 commented Oct 12, 2026

Copy link
Copy Markdown
Author

Happy to go either way here. I can move the NotFound and Conflict logging into details::handle_connection_resource_patch, at the same levels as the Locked, BadRequest and InternalError cases, so /single and /bulk behave the same, or keep it in the /bulk handler as it is now. @garethsb @lo-simon just let me know which you prefer and I'll update the PR.

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.

More log with BULK command

3 participants