linuxserver / docker-unifi-network-application

GNU General Public License v3.0
717 stars 54 forks source link

[BUG] Configuration fails when mongo password contains '%' and perhaps other special chars. #117

Closed ApexAlpha closed 1 month ago

ApexAlpha commented 1 month ago

Is there an existing issue for this?

Current Behavior

When MONGO_PASS value contains a percent sign (%) the setup fails with the following error:

[2024-10-01T11:06:07,585Z] <launcher> ERROR mongo  - Could not determine Mongo journaling state
java.lang.IllegalArgumentException: URLDecoder: Incomplete trailing escape (%) pattern

Expected Behavior

Not really something this project should have to fix, but I recommend adding a small comment in the yaml file to make users aware of this limitation.

Example:

environment:
      - MONGO_INITDB_ROOT_USERNAME=root
      - MONGO_INITDB_ROOT_PASSWORD=
      - MONGO_USER=unifi
      - MONGO_PASS=example #We recommend passwords not containing a '%'

Steps To Reproduce

  1. Setup a password containing %
  2. Launch the containers

Environment

- OS: Linux/Ubuntu
- How docker service was installed: docker apt

CPU architecture

x86-64

Docker creation

docker compose up -d

Container logs

[2024-10-01T11:06:07,204Z] <launcher> INFO  startup - Initiating startup
[2024-10-01T11:06:07,550Z] <launcher> INFO  system - ======================================================================
[2024-10-01T11:06:07,550Z] <launcher> INFO  system - UniFi 8.4.62 (build atag_8.4.62_26656 - release/release) is started
[2024-10-01T11:06:07,551Z] <launcher> INFO  system - Environment: UniFi-OS[false], UniFi-Cloud[false], UniFi-MongoService[false]
[2024-10-01T11:06:07,551Z] <launcher> INFO  system - ======================================================================
[2024-10-01T11:06:07,551Z] <launcher> INFO  system - BASE dir:/usr/lib/unifi
[2024-10-01T11:06:07,555Z] <launcher> INFO  system - Current System IP: 172.18.0.13
[2024-10-01T11:06:07,555Z] <launcher> INFO  system - Hostname: bc4b0a9f891c
[2024-10-01T11:06:07,555Z] <launcher> INFO  system - ubic.env: prod
[2024-10-01T11:06:07,555Z] <launcher> INFO  system - System loaded
[2024-10-01T11:06:07,585Z] <launcher> ERROR mongo  - Could not determine Mongo journaling state
java.lang.IllegalArgumentException: URLDecoder: Incomplete trailing escape (%) pattern
    at java.base/java.net.URLDecoder.decode(URLDecoder.java:230)
    at java.base/java.net.URLDecoder.decode(URLDecoder.java:147)
    at com.mongodb.ConnectionString.urldecode(ConnectionString.java:1239)
    at com.mongodb.ConnectionString.<init>(ConnectionString.java:387)
    at com.mongodb.ConnectionString.<init>(ConnectionString.java:321)
    at com.ubnt.service.db.A.public(Unknown Source)
    at com.ubnt.service.db.A.Object(Unknown Source)
    at com.ubnt.service.db.A.ô00000(Unknown Source)
    at com.ubnt.service.db.A.Ô00000(Unknown Source)
    at com.ubnt.service.db.I.ô00000(Unknown Source)
    at com.ubnt.service.db.I.Ö00000(Unknown Source)
    at com.ubnt.service.db.I.ÕO0000(Unknown Source)
    at com.ubnt.service.db.I.public(Unknown Source)
    at com.ubnt.service.db.I.OO0000(Unknown Source)
    at com.ubnt.service.db.I.afterPropertiesSet(Unknown Source)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1835)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1784)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:600)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:337)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:975)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:962)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:624)
    at com.ubnt.service.E.Ô00000(Unknown Source)
    at com.ubnt.service.C.intsuper(Unknown Source)
    at com.ubnt.net.C.publicObject(Unknown Source)
    at com.ubnt.net.C.floatObject(Unknown Source)
    at com.ubnt.net.C.ØÔ0000(Unknown Source)
    at com.ubnt.service.C.Òo0000(Unknown Source)
    at com.ubnt.ace.Launcher.Object(Unknown Source)
    at com.ubnt.ace.Launcher.main(Unknown Source)
[2024-10-01T11:06:07,588Z] <launcher> WARN  AnnotationConfigApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoRuntimeService' defined in com.ubnt.service.db.CoreDatabaseSpringContext: URLDecoder: Incomplete trailing escape (%) pattern
github-actions[bot] commented 1 month ago

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

aptalca commented 1 month ago

From the readme: Mongodb Password. Only evaluated on first run. Special characters must be url encoded.

ApexAlpha commented 1 month ago

Mhh, I must've read over that (a few times). My bad!