Skip to content

ID length is hardcoded (10 chars) for CLP validation #6331

@BufferUnderflower

Description

@BufferUnderflower

Issue Description

  1. By default objectIdSize is set to 10. It can be configured to any fixed length - see Add config for objectId size #3950.
  2. There is a recent addition allowing to set custom object ids #6101 Let users define objectId #6177.

During CLP validation there is a regEx allowing exactly 10 chars:

const userIdRegex = /^[a-zA-Z0-9]{10}$/;

This leads to a problem: if you decide to change objectIdSize:
CLP for user with id.length != 10 won't be accepted by schema controller.
Same for custom ids.

Steps to reproduce

  1. Launch server with objectIdSize: 11
   it('should aceept class-level permission for custom userid of any length', async done => {
    await global.reconfigureServer({
      customIdSize: 11,
    });

    const id = 'e1evenChars';

    const { data } = await request({
      method: 'POST',
      url: 'http://localhost:8378/1/schemas/AClass',
      headers: masterKeyHeaders,
      json: true,
      body: {
        classLevelPermissions: {
          find: {
            [id]: true,
          },
        },
      },
    });

    expect(data.classLevelPermissions.find[id]).toBe(true);

    done();
  });

Expected Results

schema is accepted

Actual Outcome

'e1evenChars' is not a valid key for class level permissions

Environment Setup

  • Server
    • parse-server version (Be specific! Don't say 'latest'.) : 3.10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions