Repository navigation
Bug in src/embed.js @getParser(node, opts) #810
Copy link
Copy link
Open
Sec-ant/prettier-plugin-embed
#157Labels
Description
Activity
I tried to fix this up, but I don't have much context of the upstream/downstream code.
Can you share the code you are trying to format?
@kddnewton this is a sanitized file but it is representative of the problem we are facing.
I reran prettier in our environment and saw the same error message
/** * SANITIZED VERSION FOR BUG REPORT - Original file contains actual authentication details * This file is ignored by prettier because the xml strings throw errors with prettier * I also noticed that the xml strings did not get formatted when I ran prettier on the file. * We need to audit the xml plugin + prettier embedded plugin, which seems to be broken */ import type { Temporal } from "@js-temporal/polyfill" import { xml } from "lit-xml" /** Generic authentication passport template */ export const authPassport = xml` <tokenPassport> <account>{AUTH_DOMAIN}</account> <consumerKey>{AUTH_CONSUMER_KEY}</consumerKey> <token>{AUTH_TOKEN_ID}</token> <nonce>{AUTH_NONCE}</nonce> <timestamp>{AUTH_TIMESTAMP}</timestamp> <signature algorithm='HMAC-SHA256'>{AUTH_SIGNATURE}</signature> </tokenPassport>` export const searchMoreWithId = (page: number, searchId: string) => xml` <?xml version='1.0' encoding='utf-8' ?> <soap-env:Envelope xmlns:soap-env='http://schemas.xmlsoap.org/soap/envelope/'> <soap-env:Header> ${authPassport} </soap-env:Header> <soap-env:Body> <searchMoreWithId> <searchId>${searchId}</searchId> <pageIndex>${page}</pageIndex> </searchMoreWithId> </soap-env:Body> </soap-env:Envelope> ` export const employeeSearchData = (pageSize: number) => xml` <?xml version='1.0' encoding='utf-8' ?> <soap-env:Envelope xmlns:soap-env='http://schemas.xmlsoap.org/soap/envelope/'> <soap-env:Header> ${authPassport} <searchPreferences> <pageSize>${pageSize}</pageSize> </searchPreferences> </soap-env:Header> <soap-env:Body> <search> <searchRecord xmlns:ns12='urn:common_2023_2.platform.webservices.example.com' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:type='ns12:EmployeeSearchBasic' /> </search> </soap-env:Body> </soap-env:Envelope>` export const billCustomFieldData = ( pageSize: number, customFieldId: string, after?: Temporal.Instant, before?: Temporal.Instant ) => { const dateCriteria = after && before ? xml` <lastModifiedDate operator='within'> <searchValue>${after.toString()}</searchValue> <searchValue2>${before.toString()}</searchValue2> </lastModifiedDate>` : after ? xml`<lastModifiedDate operator='after'><searchValue>${after.toString()}</searchValue></lastModifiedDate>` : before ? xml`<lastModifiedDate operator='before'><searchValue>${before.toString()}</searchValue></lastModifiedDate>` : xml`` return xml` <?xml version='1.0' encoding='utf-8' ?> <soap-env:Envelope xmlns:soap-env='http://schemas.xmlsoap.org/soap/envelope/'> <soap-env:Header> ${authPassport} <searchPreferences> <bodyFieldsOnly>false</bodyFieldsOnly> <returnSearchColumns>true</returnSearchColumns> <pageSize>${pageSize}</pageSize> </searchPreferences> </soap-env:Header> <soap-env:Body> <search> <searchRecord xsi:type='ns8:TransactionSearchAdvanced' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns8='urn:sales_2023_2.transactions.webservices.example.com' > <criteria> <basic> ${dateCriteria} <type operator='anyOf'> <searchValue>_vendorBill</searchValue> </type> </basic> </criteria> <columns> <basic> <internalId /> <customFieldList xsi:type='core:SearchColumnCustomFieldList' xmlns:core='urn:core_2023_2.platform.webservices.example.com' > <core:customField internalId='${customFieldId}' xsi:type='core:SearchColumnSelectCustomField' /> </customFieldList> </basic> </columns> </searchRecord> </search> </soap-env:Body> </soap-env:Envelope>` }
Stack trace
console.log(node)
and the function is attempting to destructured some properties that don't exist
const { Name, attribute } = node; let parser = Name.toLowerCase();thus we get the undefined TypeError
details of my machine
prettier config
command to reproduce