tinode / chat

Instant messaging platform. Backend in Go. Clients: Swift iOS, Java Android, JS webapp, scriptable command line; chatbots
GNU General Public License v3.0
12.03k stars 1.88k forks source link

Failed to parse config file: invalid character '"' after object key:value pair #337

Closed pwFoo closed 4 years ago

pwFoo commented 4 years ago

Hi @or-else, I updated my tinode docker swarm to latest and it breaks with the following error.

2020/01/08 08:15:41 Initializing mysql 110
2020/01/08 08:15:41 Failed to parse config file:invalid character '"' after object key:value pair

I started the container manually to try to do more debugging...

2020/01/08 08:15:41 Server v0.16:/opt/tinode/tinode:v0.16.3-rc4; db: 'mysql'; pid 44; 2 process(es)
2020/01/08 08:15:41 Using config from '/opt/tinode/working.config'
2020/01/08 08:15:41 Failed to parse config file: invalid character '"' after object key:value pair

Any idea why there is an invalid character in the generated config? Environment configurationen

    environment:
#      UPGRADE_DB: 'true'
#      RESET_DB: 'true'
      SMTP_SERVER: smtp.example.com
      SMTP_PORT: '25'
      SMTP_SENDER: noreply@example.com
      SMTP_HOST_URL: https://chat.example.com
      SMTP_PASSWORD: <PW_STRING>
      FCM_CRED_FILE: /path/to/file.json 
      FCM_SENDER_ID: <ID_STRING>
      FCM_VAPID_KEY: <KEY_STRING>

Any change to add the line to the error message for future debugging?

or-else commented 4 years ago

It would be trivial to add the line number but the problem is comments in json. They are stripped before parsing and that changes the line numbers. I'll look into it.

or-else commented 4 years ago

fixed.

pwFoo commented 4 years ago

Thanks, I'll deploy after new docker image is available.

pwFoo commented 4 years ago

Hi @or-else, have you fixed the error in the generated config or just improved the error message?

Waiting for the image with the fix for generated config file to test it. When will a new tinode/tinode-mysql published?

or-else commented 4 years ago

I've added more verbose error logging. I can't fix your error because I don't see it. If you need help please pull the generated config from the container and look at it. The error is likely to be obvious.

pwFoo commented 4 years ago

Hi, looks like a problem in the second line?!

{
  ½     "listen": ":18080",

Don't know how it could be config related because I don't configure / change the listen port?

or-else commented 4 years ago

Well, there is a problem in this line, but something is wrong elsewhere. The line like you have shown would produce an error invalid character 'Â' looking for beginning of object key string. But you have reported the error invalid character '"' after object key:value pair. So do please make sure you pull correct config file and the file is not corrupted.

or-else commented 4 years ago

I would guess you have quoted some string which does not need quoting. You probably have something like "key": ""value""

pwFoo commented 4 years ago

Generated config. Haven't found a possible cause by a " character.

{
        "listen": ":18080",
        "cache_control": 39600,
        "static_mount": "/",
        "grpc_listen": ":16061",
        "api_key_salt": "<KEY>",
        "max_message_size": 4194304,
        "max_subscriber_count": 32,
        "max_tag_count": 16,
        "expvar": "",

        "media": {
                "use_handler": "fs",
                "max_size": 33554432,
                "gc_period": 60,
                "gc_block_size": 100,
                "handlers": {
                        "fs": {
                                "upload_dir": "uploads"
                        },
                        "s3":{
                                "access_key_id": "",
                                "secret_access_key": "",
                                "region": "",
                                "bucket": "",
                                "cors_origin": ["*"]
                        }
                }
        },

        "tls": {
                "enabled": false,
                "http_redirect": ":80",
                "strict_max_age": 604800,
                "autocert": {
                        "cache": "/etc/letsencrypt/live/",
                        "email": "",
                        "domains": [""]
                }
        },

        "auth_config": {
                "logical_names": [],
                "basic": {
                        "add_to_tags": true,
                        "min_login_length": 3,
                        "min_password_length": 6
                },
                "token": {
                        "expire_in": 1209600,
                        "serial_num": 1,
                        "key": "<KEY>"
                }
        },

        "store_config": {
                "uid_key": "<KEY>",
                "adapters": {
                        "mysql": {
                                "database": "tinode",
                                "dsn": "root@tcp(mysql)/tinode?parseTime=true&collation=utf8mb4_unicode_ci"
                        },
                        "rethinkdb": {
                                "database": "tinode",
                                "addresses": "rethinkdb"
                        }
                        "mongodb": {
                                "database": "tinode",
                                "addresses": "mongodb",
                                "replica_set": "rs0"
                        }
                }
        },

        "acc_validation": {
                "email": {
                        "add_to_tags": true,
                        "required": ["auth"],
                        "config": {
                                "host_url": "https://chat.example.com",
                                "smtp_server": "smpt.example.com",
                                "smtp_port": "25",
                                "login": "",
                                "sender": "noreply@example.com",
                                "sender_password": "<SMTP_PW>",
                                "validation_body_templ": "./templ/email-validation-body.templ",
                                "validation_subject": "Tinode registration: confirm email",
                                "reset_body_templ": "./templ/email-password-reset.templ",
                                "reset_subject": "Reset Tinode password",
                                "headers": [],
                                "max_retries": 4,
                                "domains": [],
                                "debug_response": ""
                        }
                },

                "tel": {
                        "add_to_tags": true,
                        "config": {
                                "template": "./templ/sms-validation.templ",
                                "max_retries": 4,
                                "debug_response": ""
                        }
                }
        },

        "push": [
                {
                        "name":"fcm",
                        "config": {
                                "enabled": true,
                                "buffer": 1024,
                                "project_id": "",
                                "credentials_file": "/fcm/tinode-1586b-firebase-adminsdk-vima7-373057298f.json",
                                "time_to_live": 3600,
                                "include_android_notification": true,
                                "icon": "ic_logo_push",
                                "icon_color": "#3949AB"
                        }
                }
        ],

        "plugins": [
                {
                        "enabled": false,
                        "name": "python_chat_bot",
                        "timeout": 20000,
                        "filters": {
                                "account": "C"
                        },
                        "failure_code": 0,
                        "failure_text": null,
                        "service_addr": "tcp://localhost:40051"
                }
        ]

}
or-else commented 4 years ago

OK, here is the problem: https://github.com/tinode/chat/commit/960092cbc721d4d84a70c7e345b1e249e73100da

pwFoo commented 4 years ago

Thanks! So it should be fixed in the next build 👍

or-else commented 4 years ago

Docker has been released

pwFoo commented 4 years ago

Fixed with rc5 image. Closed. Thanks!