Meteor-Community-Packages / Meteor-Community-Packages/meteor-collection2

SimpleSchema validation succeeds but on insert fails with keyNotInSchema fro SubSchema

Open
#367 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs reproduction will accept pull request
Dominant language
JavaScript
Stars
1k
Forks
112
PR merge metrics
No merged PRs in 30d

Description

I have a schema which references a sub schema.

When I validate the schema manually with SimpleSchema.validate it succeeds. However, when I try and insert the item it fails saying the keys of the sub schema are not valid.

The exact same code works in another project. The only difference is this is based off a package based architecture so the attachSchema code is inside a package that is imported into the project.

Any suggestions of where to look for the cause?

I've checked that the sub schema is part of the schema when it is attached to the collection.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the discrepancy between SimpleSchema.validate and collection insert using the package-based attachSchema setup described in the issue. Compare the schema seen during manual validation with the schema used during insert, then document the cause and add a regression test showing that keys from the referenced sub schema are accepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mongodb
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.