inventree / InvenTree

Open Source Inventory Management System
https://docs.inventree.org
MIT License
4.07k stars 726 forks source link

Invalid SITE_URL value: InvenTree server cannot start. #7383

Closed decryptedchaos closed 2 weeks ago

decryptedchaos commented 3 months ago

Deployment Method

Describe the problem*

i have my own docker <-- Proxy (Traefik) disabling it is not an option, and i don't really think its the cause, but as such, i h ave disabled the use of caddy for inventree because my traefik is configured to auto deploy containers to a DNS wildcard containername.docker.example.com this setup should work just as Caddy does as it just proxys the dns to the container on its service port. so i don't think its a problem..

But i can't get the inventree-server to stop flapping (restarting) it just contantly loops with this error

Invalid SITE_URL value: '"http://inventree.docker.example.com"'. InvenTree server cannot start.

Yet, the variable SITE_URL is configured properly and works. the server just never starts.

Steps to Reproduce

Described above.

Relevant log output

No response

SchrodingersGat commented 3 months ago

please provide full log output for the server. And I assume the url you have provided is not your actual URL?

decryptedchaos commented 3 months ago

Yeah clearly, i just don't want my url posted publicly for obvious reasons.

There isn't really any log it just repeats what i said over and over with standard info lines above and below

Python version 3.11.9 - /usr/local/bin/python Invalid SITE_URL value: '"http://inventree.docker.*******.com"'. InvenTree server cannot start. Loading config file : /home/inventree/data/config.yaml

EDIT: I should also note, that i can ping that url (host) from any other docker container on the node, i can't test from the inventree-server because it wont stay alive long enough to get a prompt it literally restarts every second.

But i have no reason to believe that it would be any different. So i don't known what kind of validation checks your code is doing for the variable or the url itself, but there must be some kind of logical error somewhere, because my reverse proxy answers to the url, it just can't do anything because the container it's trying to point to wont actually start/run

SchrodingersGat commented 3 months ago

@decryptedchaos I tried to reproduce this fault, by using the literal URL http://inventree.docker.example.com - the server did not fail in this case. Is there perhaps something particular about the specific URL you are using?

Here is the validation being performed (in https://github.com/inventree/InvenTree/blob/cdac7465b22e0eaaf1f2d2a469f2ef32502d03db/src/backend/InvenTree/InvenTree/settings.py#L987)

image

decryptedchaos commented 3 months ago

No nothing special, the only thing that's even remotely different on my setup is that i don't use your supplied Caddy proxy like i say in my OP, because i already have a configured traefik proxy serving multiple containers that i can't simply change for one image.

Aside from that the only other thing is, i use DNS wildcards so at my DNS server *.docker.mydomain.com returns the docker server ip this shouldn't matter, lastly, the docker host is behind a NAT, but the proper ports for the proxy (80,443) are forwarded to the docker host and traefik answers and function 100% fine for other containers.

I've tried deleting everything and starting from scratch twice and its the same result every time, is there something else i need to do to purge any dangling remnants before trying to start over?

SchrodingersGat commented 3 months ago

I've tried deleting everything and starting from scratch twice and its the same result every time, is there something else i need to do to purge any dangling remnants before trying to start over?

No, I do not think that there's any "remnants" here causing this problem. There is some reason that the URL validator is failing on your particular URL.

We just use the django URLValidator class here:

https://github.com/django/django/blob/adae619426b6f50046b3daaa744db52989c9d6db/django/core/validators.py#L127

You could run a simple test on your end by passing your specific URL through the validator class and see what particular error it is throwing?

decryptedchaos commented 3 months ago

Interestingly it throws no error assuming the variable is being read between the " " from your variable and not including the "

When i pass my URL exactly as typed between the quotes it returns valid/correct. obviously if i don't include http:// or if i include the quotes it will fail. but i can't imagine why it would be passing the deliminator's or excluding parts of the string, and while it seems unlikely that's happening.

I'm at a loss because the URLvalidator function has no problem with my URL when running from a simple python try exception script i threw together, assuming it's being passed correctly from the .env file to inventree when, it should work there must be a bug here, that isn't obvious.

Because either its parsing the .env wrong or its striping out or including something in the eval that it shouldn't seems to be the only possible causes if the raw function works for my URL


EDIT:

And...

That's what it was.. your .env file included " " in .env file let me check that, yep confirmed

https://raw.githubusercontent.com/inventree/InvenTree/master/contrib/container/.env

INVENTREE_SITE_URL="http://inventree.localhost"

So i didn't think anything of it, i trusted the official .env to be correct. i removed the " " and it passed the error

Although, I seem to have database issues now, but i think that's because it wasn't parsing that URL and never getting past that exception thus never created the database so let me rerun through that and I'll let you know.


Yep, working after re-running db setup

SchrodingersGat commented 3 months ago

Ahh. ok so the extra quotes killed it, that is interesting. Might be worth automatically stripping quotes from the provided data

wolflu05 commented 3 months ago

i don't use your supplied Caddy proxy like i say in my OP, because i already have a configured traefik proxy serving multiple containers

How do you serve the static files then?

decryptedchaos commented 3 months ago

How do you serve the static files then?

Haven't really gotten that far yet, currently gnuicorn is serving them directly to my proxy, probably not efficient, but i haven't found anything that doesn't work yet. and i don't know if there is a way to get traefik to access file directly. so that could be a flaw in the setup.

But i still think its the least horrible, as compared to having Client --> Traefik --> Caddy --> gnuicorn Which i think would have been far more troublesome.

Since the server is Single IP/NAT it can only have one listener for HTTP/HTTPS that has been traefik because its ability to integrate and automatically deploy for all containers easily.

That's a pretty common way to use docker too, so i always kinda question it when projects want to use its own proxy server, because the likely only way that would work right is if you could assign a dedicated IP to that set of containers.

github-actions[bot] commented 3 weeks ago

This issue seems stale. Please react to show this is still important.