Skip to content

PATCH should create resources if they don't exist (Solid spec) #2

@melvincarvalho

Description

@melvincarvalho

Problem

PATCH requests to non-existent resources return 404, but in Solid, PATCH should be able to create resources using N3 Patch with solid:inserts.

Error from PodOS:

Web error: 404 (Not Found) on PATCH of http://localhost:3210/agsdf

Solution

Modify handlePatch to:

  1. If resource doesn't exist, start with an empty JSON-LD document ({ "@context": {}, "@graph": [] })
  2. Apply the patch to create the resource
  3. Return 201 Created instead of 204 No Content when a new resource is created

This aligns with the Solid protocol where PATCH can be used for resource creation, not just updates.

Changes

  • handlePatch now creates resources if they don't exist
  • Returns 201 for creation, 204 for updates
  • If-Match header only checked when resource exists

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions