#gl_node-html

1 messages ยท Page 1 of 1 (latest)

whole sleetBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1247589381955649596

๐Ÿ“ Have more to share? Add details, code, screenshots, videos, etc. below.

glossy sable
#

@rigid marsh can you DM me your IP address so I can try to find your request in our logs?

rigid marsh
#

Sure, one moment.

glossy sable
#

not really but that's not really the right next step

#

(I'm trying to find your requests in our logs)

rigid marsh
#

thank you, I appreciate it.

glossy sable
#

can you do one request quickly again and then nothing (not even loading the Dashboard)

#

I wonder what name: v4() is exactly and if you're sending something invalid that makes our servers crash but I can't see any recent request from your IP that isn't just loading the Dahsboard

rigid marsh
#

v4() is just a function that returns a uuid-v4

#

like I said, this was working a day or two ago

#

made another request, here's the exception:

StripeAPIError: Invalid JSON received from the Stripe API
    at /<redacted>/node_modules/stripe/cjs/RequestSender.js:111:23
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  type: 'StripeAPIError',
  raw: {
    message: 'Invalid JSON received from the Stripe API',
    exception: SyntaxError: Unexpected token '<', "<html>
    <h"... is not valid JSON
        at JSON.parse (<anonymous>)
        at IncomingMessage.<anonymous> (<redacted/node_modules/stripe/cjs/net/NodeHttpClient.js:99:34)
        at Object.onceWrapper (node:events:632:28)
        at IncomingMessage.emit (node:events:530:35)
        at endReadableNT (node:internal/streams/readable:1696:12)
        at process.processTicksAndRejections (node:internal/process/task_queues:82:21),
    requestId: undefined
  },
  rawType: undefined,
  code: undefined,
  doc_url: undefined,
  param: undefined,
  detail: undefined,
  headers: undefined,
  requestId: undefined,
  statusCode: undefined,
  charge: undefined,
  decline_code: undefined,
  payment_intent: undefined,
  payment_method: undefined,
  payment_method_type: undefined,
  setup_intent: undefined,
  source: undefined
}

glossy sable
#

Trying to figure out what is going on. Give me a few minutes

#

gl_node-html

#

@rigid marsh Can you try making a request with curl in your terminal? I want to figure out if it's the same outside of stripe-node

rigid marsh
#

what would be the corresponding URL to POST to?

glossy sable
#
  -u "sk_test_123:" \
  -d name="Jenny Rosen"```
rigid marsh
#
% curl -X POST https://api.stripe.com/v1/customers \
  -u "sk_test_123:" \
  -d name="Jenny Rosen"
{
  "error": {
    "message": "Invalid API Key provided: sk_test_123",
    "type": "invalid_request_error"
  }
}
#

should that be an Authorization header with Bearer, instead of -u?

glossy sable
#

no that all works totally fine. Just this is not your real API key. Can you put your API key in the call?

rigid marsh
#
jeremykeys@Jeremys-MacBook-Pro api % curl -X POST https://api.stripe.com/v1/customers \
  -u "sk_test_51Ow.........1kp:" \
  -d name="Jenny Rosen"
{
  "id": "cus_QETnzIUJyQ9e5B",
  "object": "customer",
  "address": null,
  "balance": 0,
  "created": 1717520841,
  "currency": null,
  "default_source": null,
  "delinquent": false,
  "description": null,
  "discount": null,
  "email": null,
  "invoice_prefix": "500B199C",
  "invoice_settings": {
    "custom_fields": null,
    "default_payment_method": null,
    "footer": null,
    "rendering_options": null
  },
  "livemode": false,
  "metadata": {},
  "name": "Jenny Rosen",
  "next_invoice_sequence": 1,
  "phone": null,
  "preferred_locales": [],
  "shipping": null,
  "tax_exempt": "none",
  "test_clock": null
}
glossy sable
#

okay so your API request works totally fine right now in the terminal. So it's definitely something with your code

#

Can you go back to your stripe-node code and hardcode the API keys

rigid marsh
#

okay

#

same thing =/

glossy sable
#

can you try passing sk_test_123 and share your exact end to end code so I can look at it?

rigid marsh
#

yeah I can DM it to you

glossy sable
#

no I mean hardcode the sk_test_123 API key and share that exact code here

#

Also damn you seem to use a client, overriding the protocol (http) and all that, this is pretty crucial information and likely the problem

#

@rigid marsh okay you seem to use something really advanced. Let's focus on really simple code instead

#

(async () => {
  const customer = await stripe.customers.create({
      name: 'testing-customer-123456789-discord',
    }
  );
  console.log("Customer created: ", customer);
})();```
Please run that exact code as a one-off script with Node.js
whole sleetBOT
rigid marsh
#

yeah, that seems to work.

% node
node
Welcome to Node.js v20.12.2.
Type ".help" for more information.
> var stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
undefined
> 
> (async () => {
...   const customer = await stripe.customers.create({
...       name: 'testing-customer-123456789-discord',
...     }
...   );
...   console.log("Customer created: ", customer);
... })();
Promise {
  <pending>,
  [Symbol(async_id_symbol)]: 32,
  [Symbol(trigger_async_id_symbol)]: 6
}
> Customer created:  {
  id: 'cus_QETvOaNSxXME8b',
  object: 'customer',
  address: null,
  balance: 0,
  created: 1717521336,
  currency: null,
  default_source: null,
  delinquent: false,
  description: null,
  discount: null,
  email: null,
  invoice_prefix: 'E18CB956',
  invoice_settings: {
    custom_fields: null,
    default_payment_method: null,
    footer: null,
    rendering_options: null
  },
  livemode: false,
  metadata: {},
  name: 'testing-customer-123456789-discord',
  next_invoice_sequence: 1,
  phone: null,
  preferred_locales: [],
  shipping: null,
  tax_exempt: 'none',
  test_clock: null
}
glossy sable
#

okay so now can you tell me more about your set up? Do you have a local proxy or something that runs on your network?

rigid marsh
#

No, my VPN (ExpressVPN) is deactivated and I don't have any proxies configured.

I don't see how a proxy would be responsible for the Stripe API returning HTML to the stripe-node client, though?

glossy sable
#

Because the code you DM-ed to me is explicitly overriding the protocol to HTTP

#

our servers refuse any connections over HTTP. It requires (and always has) HTTPS.

rigid marsh
#

I didn't write the stripeClient initialization code in question, I'm merely adding some express endpoints. When I comment out that protocol line, and use my "real" test API key, the stripe client now responds with this:

"code":"customer_tax_location_invalid","doc_url":"https://stripe.com/docs/error-codes/customer-tax-location-invalid","message":"Automatic tax calculation in Checkout requires a valid address on the Customer. Add a valid address to the Customer or set either `customer_update[address]` to 'auto' or `customer_update[shipping]` to 'auto' to save the address entered in Checkout to the Customer."
#

I'm still confused as to why this was working a couple of days ago with that protocol property set.

glossy sable
#

I am fairly confident it was never working 2 days ago and you didn't have that protocol or you didn't use that client you created

rigid marsh
#

I believe the protocol line is so that we can interact with stripe-mock.

glossy sable
#

yeah exactly, so if you use stripe-mock you set HTTP and if you don't you set HTTPS

#

so maybe you had stripe-mock at the time

rigid marsh
#

I can't really prove that it was working a couple of days ago, you'd have to take my word for it ๐Ÿ™‚

#

okay, well I'll work with the engineer who initially set this up to figure out what the correct stripe client workflow should be.

glossy sable
#

yeah I've worked for Stripe for many years and I am fairly certain it would never have worked

rigid marsh
#

okay, thanks for your help

#

By the way, it seems odd that the stripe API returns truncated, inaccessible HTML instead of a valid JSON object that clearly states the protocol is incorrect.

#

Not sure if you can take that as a feature request or not.

glossy sable
#

yeah that's fair but it's forbidden to use HTTP and it's not really hitting our normal API code, it's banning your request at the edge and it's definitely common to return html there

#
{
  "error": {
    "message" : "The Stripe API is only accessible over HTTPS.  Please see <https://stripe.com/docs> for more information.",
    "type": "invalid_request_error"
  }``` I get this in my terminal so I'll still dig into why you don't get that
rigid marsh
#

fair enough, I would just expect the edge and the stripe client to communicate in JSON when the error is well known. Not that big of a deal, I'm just sorry I had to waste your time on this.

#

thank you. Have a good rest of your day.

glossy sable
#

yeah to be clear I will file some bugs internally. I should have been able to debug this in seconds too and the log line we had had no information about why it was rejecting your request either ๐Ÿ˜…

rigid marsh
#

haha, sounds good. take care!