Skip to content

Add global DELETE /api/v1/faults endpoint (extension) #226

@mfaferek93

Description

@mfaferek93

Summary

The gateway provides GET /api/v1/faults as a convenience endpoint to list all faults across the system (regardless of entity ownership). However, there is no corresponding DELETE /api/v1/faults to clear all faults globally.

Per-entity DELETE /api/v1/{entity-path}/faults only clears faults owned by that entity. Faults reported via ROS 2 service with arbitrary source_id values aren't owned by any manifest entity, so per-entity DELETE can't clear them.

Note: This is a ros2_medkit extension, not part of the SOVD standard. SOVD is entity-centric - fault operations are scoped to entities. Our GET /api/v1/faults is already an extension; this adds the matching write operation.


Proposed solution

DELETE /api/v1/faults

Clear all faults in the system, regardless of entity ownership.

Response 204 No Content on success.

Optional query parameter:

Parameter Type Required Description
status string No Filter which faults to clear: confirmed, prefailed, all (default: confirmed)

Example:

# Clear all confirmed faults
curl -X DELETE "http://localhost:8080/api/v1/faults"

# Clear everything (including prefailed)
curl -X DELETE "http://localhost:8080/api/v1/faults?status=all"

Implementation

The fault manager already has a ClearFault service per fault code. The global DELETE handler should:

  1. Call GET /api/v1/faults (internal) to get all fault codes
  2. Call ClearFault for each fault code
  3. Return 204 when all clears complete

Alternatively, add a ClearAllFaults ROS 2 service to fault_manager_node for atomic bulk clear.

Route registration

// Extension: global fault management (not SOVD - convenience API)
srv->Delete(api_path("/faults"), handler);

Documentation

Mark clearly as extension in docs/api/rest.rst:

.. note::

   ``DELETE /api/v1/faults`` is a ros2_medkit extension, not part of the
   SOVD standard. SOVD fault operations are entity-scoped.

Additional context

Current workaround: Restart fault_manager_node with storage_type:=memory (memory is wiped on restart).

Files to modify

  • src/ros2_medkit_gateway/src/http/rest_server.cpp - Register DELETE route
  • src/ros2_medkit_gateway/src/http/handlers/fault_handlers.cpp - Implement handler
  • src/ros2_medkit_fault_manager/src/fault_manager_node.cpp - Optional: add ClearAllFaults service
  • src/ros2_medkit_msgs/srv/ - Optional: ClearAllFaults.srv
  • docs/api/rest.rst - Document endpoint with extension note
  • Unit tests + integration test

Acceptance criteria

  • DELETE /api/v1/faults clears all faults regardless of entity ownership
  • Optional status query parameter filters which faults to clear
  • Response is 204 No Content
  • Documented as ros2_medkit extension (not SOVD)
  • Unit test: clear all confirmed faults
  • Unit test: clear with status=all includes prefailed
  • Integration test: inject faults via service - DELETE - verify empty

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions