Skip to content

Talent: custom attributes error "Starting an object on a scalar field" when using fallback mode #4743

@dimip1606

Description

@dimip1606

Environment details

  • @google-cloud/talent 6.0.1
  • OS: macOS Ventura 13.5.2
  • Node.js version: 18

Steps to reproduce

Consider the following snippet:

import { v4 } from '@google-cloud/talent'

const client = new v4.JobServiceClient({ fallback: true })
const [operation] = await client.batchCreateJobs({
  parent: 'your-tenant-path',
  jobs: [
    {
      // <your other job data>
      customAttributes: {
        testAttribute: { longValues: [1], filterable: true },
      },
    },
  ],
})

const [response] = await operation.promise()

Executing it will result in the following error:

Invalid value at 'jobs[0].custom_attributes[0].value.long_values' (long_values), Starting an object on a scalar field
at GoogleError.parseHttpError (/usr/src/app/node_modules/google-gax/build/src/googleError.js:72:37)
at decodeResponse (/usr/src/app/node_modules/google-gax/build/src/fallbackRest.js:66:49)
at /usr/src/app/node_modules/google-gax/build/src/fallbackServiceStub.js:104:42
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

This only happens when using fallback mode.

When digging deeper, you will find out that in fallbackRest.ts (google-gax), the fromObject() method will transform the longValues of a custom attribute into a Long object: longValues: [ Long { low: 1, high: 0, unsigned: false } ].
This is most likely wrong, because according to the REST API of Cloud Talent Solutions, the value inside a longValues array must be of type number/string (see here).

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions