Skip to content

Add runtime validation for Service Fabric API data using Zod or similar schema library #971

@sridmad

Description

@sridmad

Is your feature request related to a problem? Please describe.

Currently, Service Fabric Explorer trusts API responses at runtime. This may lead to undetected runtime errors or silent data corruption if the API changes unexpectedly or returns malformed data.

Describe the solution you'd like

Introduce runtime validation for all raw data received from the Service Fabric API using a schema validation library such as Zod or Yup. This would:

  • Enforce validation before constructing domain models
  • Allow type-safe deserialization and better error messages
  • Enable safer code evolution and improve developer confidence

Additional context

  • Create validation schemas for all raw types in RawDataTypes.ts
  • Add error handling/reporting for failed validations
  • Add or extend unit/integration tests to cover invalid/malformed input
  • Early detection of breaking API changes
  • Stronger type guarantees project-wide
  • Example:
import { z } from 'zod';

const RawNodeSchema = z. object({
    Id: z.object({ Id: z. string() }),
    NodeName: z.string(),
    NodeStatus: z.string(),
    IsSeedNode: z.boolean(),
    // ...  
});

export function validateRawNode(data: unknown): IRawNode {
    return RawNodeSchema.parse(data);
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions