Skip to content

why errors get swallowed? #2874

Closed
Closed

Description

@Mng-dev-ai

Link to reproduction

n/a

To Reproduce

Create a collection with the following code:

export function Virtual(props) {
    const Virtual = {
        type: 'json',
        ...props,
        admin: {
            hidden: true,
            ...props.admin,
        },
        hooks: {
            beforeChange: [
                ({ siblingData }) => {
                    siblingData[props.name] = undefined;
                },
            ],
            afterRead: [props.computed],
        },
    };
    return Virtual;
}

const Sandbox = {
    slug: 'sandbox',
    fields: [
        Virtual({
            name: 'virtual',
            computed: (data) => {
                return {}; // some logic
            },
        }),
    ],
};

export default Sandbox;

Describe the Bug

When the server reloads you'll see the following error:

Collection "sandbox" > Field "virtual" > "value" does not match any of the allowed types

but the actual error is about computed not being allowed in a field definition

Payload Version

1.9.2

Activity

  1. ssyberg commented on Jun 20, 2023

    @ssyberg
    Contributor

    Have frequently experienced this when doing dev and not being vigilant about watching hot reloads, only workaround I've found is commenting out all fields and reintroducing them one by one back into the collection.

  2. self-assigned this
    on Jun 26, 2023
  3. jmikrut commented on Jun 26, 2023

    @jmikrut
    Member

    Hey all, this is actually just how our implementation of Joi schema validation works. Nested errors are fairly difficult to report properly.

    As of now, this is technically functioning as we intended, although I do agree that more work should be done here to make these nested errors surface more gracefully. I will convert this to a roadmap item and then address it accordingly with the team soon.

    Looking forward to seeing these cleaned up a bit for sure. Thanks for bringing this up!

  4. locked and limited conversation to collaborators on Jun 26, 2023
  5. converted this issue into a discussion #2906 on Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

status: needs-triagePossible bug which hasn't been reproduced yet

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions