Skip to content

redact() fails due to property with only a getter #24

@adriencohen

Description

@adriencohen

Hello,

When attempting to redact a GaxiosError object, the redact() function throws a TypeError due to trying to set a read-only property:

TypeError: Cannot set property data of #<Body> which has only a getter

Steps to Reproduce

const pinoRedact = require('@pinojs/redact')
const { request } = require('gaxios')

const redact = pinoRedact({
  paths: ['response.data'],
  censor: '[REDACTED]'
})

async function test() {
  try {
    await request({
      url: 'https://httpbin.org/status/401'
    })
  } catch (error) {
    const redactedError = redact(error) // Throws TypeError here
    return redactedError
  }
}

test().catch(err => console.error('Unexpected error:', err))

Environment

  • @pinojs/redact version: 0.4.0
  • gaxios version: 7.1.3
  • Node.js version: 22.16.0

Would it possible to fix this behavior, or is the only solution to not pass an object like that to pino ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions