Skip to content

UserProfileFunctions.cs: Deserialization errors return generic 400 with no structured logging #64

@AB-Law

Description

@AB-Law

Problem

When request body deserialization fails in UserProfileFunctions, the handler returns a generic BadRequest("Invalid request body.") with no log entry:

File: PluckIt.Functions/Functions/UserProfileFunctions.cs:63

catch (JsonException)
{
    return new BadRequestObjectResult("Invalid request body.");
}

Operators have no way to see what payload caused the failure, which field was missing, or how often this happens.

Proposed Fix

Add structured logging before returning:

catch (JsonException ex)
{
    logger.LogWarning(ex, "Profile deserialization failed for request to {Path}", req.Path);
    return new BadRequestObjectResult("Invalid request body.");
}

Functionality Impact

None. Same 400 response to callers, but now logged for operators.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions