Skip to main content

Troubleshooting Duplicate Asset Code

Summary

This page covers create or update rejections caused by a duplicate asset code. Asset code uniqueness is enforced per tenant in the application layer through a code-exists check, not through a database unique index on the code column. The only database unique index is on the numeric CompatId. When a create or update is rejected as a conflict, the cause is that another asset in the same tenant already uses the code, subject to the case handling defined by the code value object.

Audience

Support engineers and developers investigating a conflict response on asset create or update where the code is suspected to be a duplicate.

Symptoms

  • A create or update is rejected as a conflict.
  • A user reports "code already exists" when adding or editing an asset.
  • The same code appears intended for two assets within one tenant.

Cause

Scope

This page covers per-tenant code uniqueness only. Other conflict conditions, such as workflow-managed direct actions, are covered on their own pages.

Likely causes

  • Another asset in the same tenant already uses the code, and the application code-exists check rejected the new value.
  • The code differs only by case or formatting that the code value object treats as equivalent.
  • A retry re-submitted a code that a prior successful attempt already persisted.

Resolution

Safe diagnostics

  • List assets for the tenant and look for the code in question; this is a read-only confirmation.
  • Compare the intended code against existing codes, accounting for the case handling of the code value object.
  • Confirm whether a prior attempt already succeeded, which would explain a conflict on retry.
  • Do not assume a database unique index on code; uniqueness is application-enforced per tenant, so the check is logical rather than a schema constraint.

Validation

  • Confirm that exactly one asset holds the code within the tenant after the intended change.
  • Confirm that a distinct, non-conflicting code is accepted where a new asset is required.
  • Confirm the CompatId unique index is not the source of the conflict, which would point to identity mapping rather than code.

Evidence to Collect

  • The code value submitted and the tenant.
  • The list of existing codes that match or nearly match.
  • The response status and message.
  • A correlation identifier and timestamp.

Escalation

Route uniqueness-rule questions and case-handling behavior to the asset or backend team. Route CompatId index conflicts to the asset team as an identity-mapping concern.

Source References

  • microservices/src/asset-service/Application/Commands/AssetCommands.cs
  • microservices/src/asset-service/Infrastructure/Persistence.cs
  • microservices/src/asset-service/Domain/Asset/Asset.cs

See Also

Keywords

duplicate code, uniqueness, conflict, per-tenant, compatid

Revision Information

  • Status: Draft
  • Last reviewed: 2026-07-17
  • Review cycle: Quarterly