# GetProductAttribute

## Overview

GetProductAttribute retrieves a single product attribute record by id or code. The input is a union type — callers specify exactly one lookup field. This serves as the core attribute lookup for existence checks, type validation, and attribute management commands.

## Business Rules

- Accepts one of two lookup variants:
  - `{ id }` — retrieves by unique identifier (used for existence checks and attribute operations)
  - `{ code }` — retrieves by attribute code (used for uniqueness validation during creation; code is immutable after creation)
- Returns the full attribute record including all fields (id, code, name, timestamps)
- Returns null if no matching attribute is found
- All comparisons are exact (case-sensitive)

## Process Flow

```mermaid
flowchart TD
    A[Receive input] --> B{Which field?}
    B -->|id| C[SELECT from ProductAttribute where id = input.id]
    B -->|code| D[SELECT from ProductAttribute where code = input.code]
    C --> E{Attribute found?}
    D --> E
    E -->|Yes| F[Return attribute record]
    E -->|No| G[Return null]
```

## External Dependencies

- None

## Error Scenarios

- **ATTRIBUTE_NOT_FOUND**: Specified attribute ID does not exist

## Test Cases

- returns attribute when found
- returns null when not found
- returns attribute when found
- returns null when not found
