apostrophecms / apostrophe

A full-featured, open-source content management framework built with Node.js that empowers organizations by combining in-context editing and headless architecture in a full-stack JS environment.
https://apostrophecms.com
Other
4.36k stars 590 forks source link

3.0: Relationship type fields cause crashes in case they are part of an array field #2586

Closed joeinnes closed 3 years ago

joeinnes commented 3 years ago

PLEASE NOTE: make sure the bug exists in the latest patch level of your major version of Apostrophe. For instance, if you are running a 2.x version of Apostrophe, you should use the latest in that major version to confirm the bug.

To Reproduce

Step by step instructions to reproduce the behavior:

  1. Create a new piece type, and add an 'array' field
  2. Add a 'relationship' type field to the array
  3. Attempt to add a new piece of this type using the front end

Expected behavior

Relationship types should not cause a crash when included as part of an array.

Describe the bug

A clear and concise description of what the bug is.

The application crashes with the following error:

TypeError: fn is not a function
    at Object._get (/Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/schema/lib/joinr.js:208:12)
    at Object._has (/Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/schema/lib/joinr.js:191:20)
    at byArray (/Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/schema/lib/joinr.js:66:17)
    at Object.relationshipDriver (/Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/schema/index.js:1520:15)
    at Object.relate (/Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/schema/index.js:797:21)
    at Object.relate (/Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/schema/index.js:1750:52)
    at Object.load (/Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/widget-type/index.js:188:32)
    at Object.after (/Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/doc-type/index.js:1256:29)
    at Object.after (/Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/doc-type/index.js:1746:29)
    at processTicksAndRejections (node:internal/process/task_queues:93:5)
    at async Object.toArray (/Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/doc-type/index.js:1494:11)
    at async Object.toObject (/Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/doc-type/index.js:1456:27)
    at async Object.withLock (/Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/page/index.js:638:18)
    at async /Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/module/index.js:124:30

Details

Version of Node.js: PLEASE NOTE: Only stable LTS versions (10.x and 12.x) are fully supported but we will do our best with newer versions. v15.2.0

Server Operating System: The server (which might be your dev laptop) on which Apostrophe is running. Linux? MacOS X? Windows? Is Docker involved? macOS Big Sur

Additional context:

So far, only fix I found is to manually remove these from the doc, after which the application will start back up again. It's worth noting that other field types are working fine, it's only relationship fields which aren't working in arrays.

Screenshots If applicable, add screenshots to help explain your problem.

boutell commented 3 years ago

Thank you for reporting a bug in 3.x alpha! We'll take a look.

boutell commented 3 years ago

There is a PR resolving this. Thanks for your input on it!

On Wed, Nov 25, 2020 at 5:10 AM Joe Innes notifications@github.com wrote:

PLEASE NOTE: make sure the bug exists in the latest patch level of your major version of Apostrophe. For instance, if you are running a 2.x version of Apostrophe, you should use the latest in that major version to confirm the bug. To Reproduce

Step by step instructions to reproduce the behavior:

  1. Create a new piece type, and add an 'array' field
  2. Add a 'relationship' type field to the array
  3. Attempt to add a new piece of this type using the front end

Expected behavior

Relationship types should not cause a crash when included as part of an array.

Describe the bug

A clear and concise description of what the bug is.

The application crashes with the following error:

TypeError: fn is not a function at Object._get (/Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/schema/lib/joinr.js:208:12) at Object._has (/Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/schema/lib/joinr.js:191:20) at byArray (/Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/schema/lib/joinr.js:66:17) at Object.relationshipDriver (/Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/schema/index.js:1520:15) at Object.relate (/Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/schema/index.js:797:21) at Object.relate (/Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/schema/index.js:1750:52) at Object.load (/Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/widget-type/index.js:188:32) at Object.after (/Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/doc-type/index.js:1256:29) at Object.after (/Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/doc-type/index.js:1746:29) at processTicksAndRejections (node:internal/process/task_queues:93:5) at async Object.toArray (/Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/doc-type/index.js:1494:11) at async Object.toObject (/Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/doc-type/index.js:1456:27) at async Object.withLock (/Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/page/index.js:638:18) at async /Users/joe/[snip]/node_modules/apostrophe/modules/@apostrophecms/module/index.js:124:30

Details

Version of Node.js: PLEASE NOTE: Only stable LTS versions (10.x and 12.x) are fully supported but we will do our best with newer versions. v15.2.0

Server Operating System: The server (which might be your dev laptop) on which Apostrophe is running. Linux? MacOS X? Windows? Is Docker involved? macOS Big Sur

Additional context:

So far, only fix I found is to manually remove these from the doc, after which the application will start back up again. It's worth noting that other field types are working fine, it's only relationship fields which aren't working in arrays.

Screenshots If applicable, add screenshots to help explain your problem.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/apostrophecms/apostrophe/issues/2586, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAH27MMPQQFNEJR76IZS2DSRTJYBANCNFSM4UCFW6JA .

--

THOMAS BOUTELL | CHIEF TECHNOLOGY OFFICER APOSTROPHECMS | apostrophecms.com | he/him/his