Skip to content

Conversation

@kamilogorek
Copy link
Contributor

@kamilogorek kamilogorek commented Oct 15, 2021

Making this change allows people to use sentry-cli configured URL for chunks upload, instead of relying on fixed URL configured in the on-premise instance.

sentry-cli handles relative URLs nicely already, so there are no changes needed there: https://github.com/getsentry/sentry-cli/blob/master/src/api.rs#L395-L405

It won't break anything sentry-side, as we check for prefix existence and add it if necessary here: https://github.com/getsentry/sentry/blob/master/src/sentry/api/client.py#L39-L42

I was trying to use reverse() here to get an endpoint prefix, but I cannot make it work. If anyone has a better idea of how to make /api/0 prefix generic in this function, I'm all ears.

Fixes getsentry/sentry-cli#839
Closes getsentry/sentry-cli#862


url = reverse("sentry-api-0-chunk-upload", args=[organization.slug])
endpoint = urljoin(endpoint.rstrip("/") + "/", url.lstrip("/"))
if len(endpoint) == 0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC system.upload-url-prefix is registered with None as default value:

register("system.upload-url-prefix", flags=FLAG_PRIORITIZE_DISK)

This means this len() will raise a TypeError if the option is not set. I think the pythonic way to write this is if not endpoint:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been written like this for 4 years now, so I didn't want to change this, as I don't know the history of this code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right, that if condition was already there. hum. i think this is weird and we somehow got lucky so far. but i guess we have some confidence this won't blow up in prod so i don't mind 😄


url = reverse("sentry-api-0-chunk-upload", args=[organization.slug])
endpoint = urljoin(endpoint.rstrip("/") + "/", url.lstrip("/"))
if len(endpoint) == 0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right, that if condition was already there. hum. i think this is weird and we somehow got lucky so far. but i guess we have some confidence this won't blow up in prod so i don't mind 😄

@kamilogorek kamilogorek merged commit bafcd24 into master Oct 19, 2021
@kamilogorek kamilogorek deleted the upload-chunks-endpoint branch October 19, 2021 09:06
@github-actions github-actions bot locked and limited conversation to collaborators Nov 3, 2021
@kamilogorek kamilogorek changed the title ref(api): Use relative endpoint for ChunkUploadEndpoint if upload-url-refix is absent ref(api): Use relative endpoint for ChunkUploadEndpoint if upload-url-prefix is absent Jan 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature-request] Add a configuration for upload-url

3 participants