#22117·meshery

[Server] Local environment updates overwrite immutable metadata

Author: maverickaayushCreated Sep 27, 2026Updated Sep 28, 2026

Description

Updating an environment through the local provider overwrites immutable/server-owned metadata. In addition to accepting a different organization, it resets createdAt to the update time and replaces the existing owner with the nil UUID.

Current Behavior

After updating only the environment name/description, the stored row has the payload's organization ID, a new creation timestamp, and a zero owner rather than the original values.

Expected Behavior

The REST contract states that an environment's organization cannot be changed after creation. createdAt and owner are response/server-owned fields and should also remain unchanged during a payload update.

Steps to Reproduce

  1. Persist an environment with known organizationId, createdAt, and owner.
  2. Call DefaultLocalProvider.UpdateEnvironment for that ID with a payload containing a different organization.
  3. Reload the row.
  4. Observe all three metadata fields were overwritten.

Evidence

$ go test ./server/models -run '^TestReproLocalEnvironmentUpdatePreservesImmutableFields$' -count=1
organization changed from <original-org> to <payload-org>
createdAt changed from <original-time> to <update-time>
owner changed from <owner-id> to 00000000-0000-0000-0000-000000000000
FAIL

Root Cause

DefaultLocalProvider.UpdateEnvironment constructs a brand-new Environment from the update payload, setting CreatedAt: time.Now(), taking OrganizationID from the payload, and setting Owner to the nil UUID. It does not load and preserve the stored entity's immutable fields.

Affected Components

  • Meshery Server
  • Local provider
  • Environment persistence/API contract

Validation

Executed on master commit 5b75615243e92b088b4ebf6e7bff82d6f60e5462:

go test ./server/models -run '^TestReproLocalEnvironmentUpdatePreservesImmutableFields$' -count=1

Result: deterministic failure; organization, creation time, and owner all change.

Acceptance Criteria

  • Updating an environment preserves its original organization, creation timestamp, and owner.
  • Only mutable payload fields are changed.
  • A regression test covers attempted organization changes and server-owned metadata.

References