Skip to content

Attachment API isn't working as expected #5080

Description

@yousefa00

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/node

SDK Version

6.19.6

Framework Version

No response

Link to Sentry event

No response

Steps to Reproduce

Any idea why this might not be working for me? I have the following Sentry configuration:

constattachmentUrlFromDsn=(dsn: DsnComponents,eventId: string)=>{const{ host, path, projectId, port, protocol, user }=dsnreturn`${protocol}://${host}${port!=='' ? `:${port}` : ''}${path!=='' ? `/${path}` : ''}/api/${projectId}/events/${eventId}/attachments/?sentry_key=${user}&sentry_version=7&sentry_client=custom-javascript`}exportconstattachAsJson=async(attachments: string[],event: Sentry.Event,client: any)=>{constdsn=client?.getDsn()if(!dsn||!event.event_id){return}constendpoint=attachmentUrlFromDsn(dsn,event.event_id)logger.info(endpoint)constformData=newFormData()for(constattachmentofattachments){formData.append('attachments',attachment)}logger.info(formData)try{awaitaxios.request({method: 'POST',url: endpoint,data: formData,headers: {'Content-Type': `multipart/form-data; boundary=${formData.getBoundary()}`}})returnevent}catch(err){logger.error(err)returnnull}}

And include this where the attachment is in scope:

Sentry.addGlobalEventProcessor(asyncevent=>{try{constclient=Sentry.getCurrentHub().getClient()if(!client){returnnull}awaitattachAsJson([attachment],event,client)}catch(ex){logger.error(ex)}returnevent})

Expected Result

An event is created with the relevant attachment.

Actual Result

I see the Sentry events created correctly, and logging the attachment API request status code is 201 created, yet there are no attachments on the actual event created. Any help would be greatly appreciated.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions