-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
parsePhoneNumberWithError metadata
argument was passed but it's not a valid metadata
#468
Comments
Hi. I see. Thx for the report. I dunno. Wontfix.
…On Wed, 4 Sep 2024 at 05:53, m2xilon ***@***.***> wrote:
Getting an error when calling parsePhoneNumberWithError(mobileNumber,
countryCode) in google cloud functions pubsub
libphonenumber-js versions affected: 1.11.3, 1.11.7
When: Encountered it only yesterday but unsure when exactly it was
introduced, though must have been recent.
What: This is the error we have been getting:
[libphonenumber-js] metadataargument was passed but it's not a valid
metadata. Must be an object having.countries child object property. Got
an object of shape: { default }. at validateMetadata
***@***.***/node_modules/libphonenumber-js/source/metadata.js:463:9)
at Metadata ***@***.***/node_modules/libphonenumber-js/source/metadata.js:23:3)
at parse ***@***.***/node_modules/libphonenumber-js/source/parse.js:72:13)
at parsePhoneNumberWithError
***@***.***/node_modules/libphonenumber-js/source/parsePhoneNumberWithError_.js:4:9)
at parsePhoneNumberWithError
***@***.***/node_modules/libphonenumber-js/source/parsePhoneNumberWithError.js:6:9)
at call ***@***.***/node_modules/libphonenumber-js/min/index.cjs.js:14:14)
at parsePhoneNumberWithError
***@***.***
/node_modules/libphonenumber-js/min/index.cjs.js:31:9)
Code:
import { parsePhoneNumberWithError } from 'libphonenumber-js'
export const validatedMobileNumber = (input: string, countryCode: CountryCode) => {
try {
const phoneNumber = parsePhoneNumberWithError(input, countryCode) // error occurs here
} catch (error) {
logger?.info(`Error when parsing ${input} with parsePhoneNumberWithError`, error.message)
throw error
}
// code never reaches here
return phoneNumber.format('E.164')
}
This same code when running from a js script with node works as expected.
But when deployed throws the error.
A workaround for a related package has been found by @nikita.rybak
<https://gitlab.com/nikita.rybak> here (see comment from 23rd of August):
https://gitlab.com/catamphetamine/react-phone-number-input/-/issues/141
Using this
import { parsePhoneNumberWithError } from 'libphonenumber-js/core'
import phoneNumberMetadata from 'libphonenumber-js/mobile/metadata'
...
phoneNumber = parsePhoneNumberWithError(input, countryCode, phoneNumberMetadata)
...
Presently an issue for some using as per the readme.
—
Reply to this email directly, view it on GitHub
<#468>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADUP3ZQWC6YFUK2TW5TSLDZUZY2VAVCNFSM6AAAAABNTLDS5CVHI2DSMVQWIX3LMV43ASLTON2WKOZSGUYDIMJYGI4TSOI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Encountered same issue when updating from 1.10.48 to 1.11.14 without any changes to our code. In our case usage is via
We are using Typescript, which apparently want to try to use the I can confirm that the metadata that is
Then the logged value for I see you have an interoperability hack a few lines below this for |
Getting an error when calling parsePhoneNumberWithError(mobileNumber, countryCode) in google cloud functions pubsub (using Cloud Functions v1)
libphonenumber-js versions affected: 1.11.3, 1.11.7
When: Encountered it only yesterday but unsure when exactly it was introduced, though must have been recent.
What: This is the error we have been getting:
[libphonenumber-js]
metadataargument was passed but it's not a valid metadata. Must be an object having
.countrieschild object property. Got an object of shape: { default }. at validateMetadata (/workspace/node_modules/.pnpm/[email protected]/node_modules/libphonenumber-js/source/metadata.js:463:9) at Metadata (/workspace/node_modules/.pnpm/[email protected]/node_modules/libphonenumber-js/source/metadata.js:23:3) at parse (/workspace/node_modules/.pnpm/[email protected]/node_modules/libphonenumber-js/source/parse.js:72:13) at parsePhoneNumberWithError (/workspace/node_modules/.pnpm/[email protected]/node_modules/libphonenumber-js/source/parsePhoneNumberWithError_.js:4:9) at parsePhoneNumberWithError (/workspace/node_modules/.pnpm/[email protected]/node_modules/libphonenumber-js/source/parsePhoneNumberWithError.js:6:9) at call (/workspace/node_modules/.pnpm/[email protected]/node_modules/libphonenumber-js/min/index.cjs.js:14:14) at parsePhoneNumberWithError (/workspace/node_modules/.pnpm/[email protected]/node_modules/libphonenumber-js/min/index.cjs.js:31:9)
Code:
This same code when running from a js script with node works as expected. But when deployed throws the error.
A workaround for a related package has been found by @nikita.rybak here (see comment from 23rd of August): https://gitlab.com/catamphetamine/react-phone-number-input/-/issues/141
Using this
Presently an issue for some using as per the readme.
The text was updated successfully, but these errors were encountered: