10000 DatabaseFake can return shared references, not copies, causing bugs · Issue #6680 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content
DatabaseFake can return shared references, not copies, causing bugs #6680
Closed as not planned
@Emyrk

Description

@Emyrk

A bug was found in dbfake because the returned template has a map field. This map field was modified in the api route. The modification was not done in a database call, but just adding key/value to the map. This modification was then reflected in the db, even though no db calls was had.

The issue is our dbfake can return structs, that when modified, are also modified in the dbfake memory store. We should return copies of data, such that no external modifications are mirrored in the database.

See: #6679

Ideas

  • A linter to prevent returning any struct with possible reference fields? Maps + Slices could be an issue?
  • Some sort of "DeepCopy()" or "Clone" func on all types? (Ugly 😢)

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

      0