Skip to content

BUG: Fix inconsistent error return values: return nil instead of []string{""} for GetTrustAnchorIDs methods #351

@Sukuna0007Abhi

Description

@Sukuna0007Abhi

Issue Description:

Problem

Currently, several GetTrustAnchorIDs methods across different scheme handlers return []string{""} (slice with empty string) when encountering errors, instead of returning nil. This is inconsistent and can cause issues downstream where empty string IDs might be processed as valid identifiers.

Root Cause

The pattern of returning []string{""} on errors appears to be a leftover from earlier implementations and doesn't follow Go best practices for error handling. When an error occurs, the function should return nil for the slice and a proper error value.

Files Affected

The following files contain this pattern:

  • trustedservices_grpc.go
  • vts/schemes/cca-realm-token/store.go
  • vts/schemes/cca-ssd-token/store.go
  • vts/schemes/tpm-enacttrust/store.go
  • vts/schemes/psa-iot/store.go
  • vts/schemes/parsec-tpm/store.go
  • vts/attestation_grpc.go
  • Expected Behavior
  • All GetTrustAnchorIDs methods should return nil (not []string{""}) when encountering errors, along with the appropriate error value.

Additional Context

This issue was identified during code review of PR #338. The mentor sir @setrofim noted: "refvalID should never be "". If they can occur now, then that is a bug that should be fixed elsewhere, not suppressed here."

This change will improve consistency across the codebase and prevent potential issues where empty string IDs might be treated as valid reference values

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions