Skip to content

Auto-generate service/resource path constants to prevent error string inconsistencies #75

@yimsk

Description

@yimsk

Problem

PR #71 renamed directories to kebab-case, but ~36 error strings in DAO files were missed and still use old names:

// Current (inconsistent)
apperrors.Wrap(err, "new sagemaker/trainingjobs dao")

// Expected
apperrors.Wrap(err, "new sagemaker/training-jobs dao")

This only affects debug output, not functionality, but causes confusion when debugging.

Proposal

Extend gen-imports to generate a constant in each resource package:

// Auto-generated in each register.go or new constants.go
const ServiceResource = "sagemaker/training-jobs"

Then use in DAO files:

apperrors.Wrap(err, "new "+ServiceResource+" dao")

Benefits

  • Error strings always match directory structure
  • No manual maintenance
  • Prevents future inconsistencies

Alternatives Considered

  1. Custom lint rule - Detects but doesn't fix
  2. Runtime package path - Adds complexity, reflection overhead

Tasks

  • Extend gen-imports to generate ServiceResource constant per package
  • Update DAO files to use the constant
  • Fix existing ~36 inconsistent error strings

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions