Skip to content

Payload api not respecting schema , fields in db but not in schema are sent as api response #11077

Open
@geminigeek

Description

@geminigeek

Describe the Bug

hi,
Payload api (mongodb) is not respecting schema , all keys for a record in db are sent as response which are not defined in collection fields , this is a good feature but it should be enabled behind a flag not by default !

to explain in simple term if i have few extra keys for a db record, which are not defined in a collection fields, those keys are also sent in payload api response !

Link to the code that reproduces this issue

not required

Reproduction Steps

  1. add a key for a record in db (mongodb compass or some thing else) which is not defined in payload collection field
  2. fetch that record with payload api the key which you added in db will be sent with api response. this should not be enabled by default , its ok to have this behind a flag/option

Which area(s) are affected? (Select all that apply)

area: core

Environment Info

Binaries:
  Node: 22.11.0
  npm: 10.9.0
  Yarn: 1.22.22
  pnpm: 9.13.0
Relevant Packages:
  payload: 3.22.0
  next: 15.1.5
  @payloadcms/db-mongodb: 3.22.0
  @payloadcms/email-nodemailer: 3.22.0
  @payloadcms/graphql: 3.22.0
  @payloadcms/next/utilities: 3.22.0
  @payloadcms/payload-cloud: 3.22.0
  @payloadcms/richtext-lexical: 3.22.0
  @payloadcms/translations: 3.22.0
  @payloadcms/ui/shared: 3.22.0
  react: 19.0.0
  react-dom: 19.0.0
Operating System:
  Platform: linux
  Arch: x64
  Version: #47-Ubuntu SMP PREEMPT_DYNAMIC Fri Sep 27 21:40:26 UTC 2024
  Available memory (MB): 112478
  Available CPU cores: 12

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions