# UpdateProductAttribute

## Permission Scope

productCatalog

## Overview

updateProductAttribute modifies the display name of an existing product attribute. The attribute can be looked up by `id` or `code`. In extensible module configurations, consumer-defined custom fields may also be updated through this command.

## Business Rules

- Target attribute must exist (looked up by `id` or `code`)
- At least one updatable field must be provided
- Name must remain non-empty when provided
- Consumer-defined custom fields may be updated

## Process Flow

```mermaid
flowchart TD
    A[Receive update request] --> B{Lookup by id or code}
    B -->|Not found| C[Return error: ATTRIBUTE_NOT_FOUND]
    B -->|Found| D{Any updatable fields provided?}
    D -->|No| E[Return error: MISSING_REQUIRED_FIELD]
    D -->|Yes| F[Apply name and/or custom field updates]
    F --> G[Return updated attribute]
```

## External Dependencies

- None

## Error Scenarios

- **ATTRIBUTE_NOT_FOUND**: Specified attribute ID does not exist
- **MISSING_REQUIRED_FIELD**: One or more required fields are missing or empty

## Test Cases

- returns error when attribute not found
- returns error when no fields provided
- returns error when name is empty string
- passes custom fields through to update
- updates name successfully
- looks up attribute by code and updates name
