JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1  
Old 25.08.2019, 03:15
darkdragon-001 darkdragon-001 is offline
JD Alpha
 
Join Date: Sep 2018
Posts: 20
Default Config parsing

When I create an incomplete configuration file for a captcha solver, I can't open the settings in the GUI afterwards.

I suggest to use the default values for all not explicitly specified settings instead.
Reply With Quote
  #2  
Old 26.08.2019, 16:13
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 64,732
Default

Can you please provide an example? It's already that way that the config system will use default values that are not set in configuration file. So my first guess is that you set invalid values
__________________
JD-Dev & Server-Admin
Reply With Quote
  #3  
Old 26.08.2019, 16:13
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 64,732
Default

You can also send example to support@jdownloader.org
__________________
JD-Dev & Server-Admin
Reply With Quote
  #4  
Old 26.08.2019, 23:06
darkdragon-001 darkdragon-001 is offline
JD Alpha
 
Join Date: Sep 2018
Posts: 20
Default

You are right, I had a type mismatch in my python script ('true' != True)!

Nevertheless, you should resolve such type mismatches instead of failing to create a dialog. In the simplest case this means replacing by default value. Maybe log this to some debug log as well.
Reply With Quote
  #5  
Old 27.08.2019, 14:28
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 64,732
Default

That's why I've asked for example because I need to know what happened that it crashes that badly.
__________________
JD-Dev & Server-Admin
Reply With Quote
  #6  
Old 27.08.2019, 14:31
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 64,732
Default

Quote:
Originally Posted by darkdragon-001 View Post
Nevertheless, you should resolve such type mismatches instead of failing to create a dialog.
Either the configuration is correct syntax and can be read or it's invalid syntax and then won't be parsed at all. And this is what happens here.
It fails to parse the config and as a result somewhere in code a check is missing -> causing issue


Quote:
Originally Posted by darkdragon-001 View Post
Maybe log this to some debug log as well.
The log contains this error. So either you provide the logs or you can give me example to reproduce the issue
__________________
JD-Dev & Server-Admin
Reply With Quote
  #7  
Old 28.08.2019, 20:56
darkdragon-001 darkdragon-001 is offline
JD Alpha
 
Join Date: Sep 2018
Posts: 20
Default

Quote:
Originally Posted by Jiaz View Post
Either the configuration is correct syntax and can be read or it's invalid syntax and then won't be parsed at all. And this is what happens here.
It fails to parse the config and as a result somewhere in code a check is missing -> causing issue
It is correct syntax but wrong type!

Quote:
Originally Posted by Jiaz View Post
That's why I've asked for example because I need to know what happened that it crashes that badly.
In case it was not clear in my previous post, the erroneous 9kw config file looked like this (of course I replaced my API key):

Code:
{
    "enabled": "true",
    "apiKey": "MYAPIKEY"
}
Reply With Quote
  #8  
Old 29.08.2019, 17:04
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 64,732
Default

Quote:
Originally Posted by darkdragon-001 View Post
It is correct syntax but wrong type!
I'm sorry for having been unclear but of course I meant both.



Quote:
Originally Posted by darkdragon-001 View Post
In case it was not clear in my previous post, the erroneous 9kw config file looked like this (of course I replaced my API key):
Code:
{
    "enabled": "true",
    "apiKey": "MYAPIKEY"
}
Thanks, I could reproduce the issue and added auto conversion from string to boolean/numbers in this config system
__________________
JD-Dev & Server-Admin
Reply With Quote
  #9  
Old 29.08.2019, 17:05
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 64,732
Default

Quote:
Originally Posted by darkdragon-001 View Post
Nevertheless, you should resolve such type mismatches instead of failing to create a dialog.
In this case I don't see any need for this as you manually changed/created configuration files and used wrong syntax/type.


Quote:
Originally Posted by darkdragon-001 View Post
In the simplest case this means replacing by default value.
I'm against auto replacing by default value if the application doesn't expect this. I've added auto conversion from string -> boolean/numbers and will also add optional *auto replace by default*
__________________
JD-Dev & Server-Admin

Last edited by Jiaz; 29.08.2019 at 17:14.
Reply With Quote
  #10  
Old 29.08.2019, 19:22
darkdragon-001 darkdragon-001 is offline
JD Alpha
 
Join Date: Sep 2018
Posts: 20
Default

When the type is wrong, the value can't be used anyway. So instead of failing, I suggest to log the old value as well the actual and expected types so that the user can investigate and replace by default value as it is done for non-existing ones.
Reply With Quote
  #11  
Old 30.08.2019, 10:36
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 64,732
Default

Quote:
Originally Posted by darkdragon-001 View Post
When the type is wrong, the value can't be used anyway. So instead of failing, I suggest to log the old value as well the actual and expected types so that the user can investigate and replace by default value as it is done for non-existing ones.
There is no *old* value?! Or what do you mean by *old* value?
This only happens when you manually modify/create the files and the log contains the exception(ClassCastException)
__________________
JD-Dev & Server-Admin
Reply With Quote
  #12  
Old 30.08.2019, 10:53
darkdragon-001 darkdragon-001 is offline
JD Alpha
 
Join Date: Sep 2018
Posts: 20
Default

With *old* value I mean the erroneous one from the config file, the one you try to cast but fail to do so. So you could just catch the exception and in the catch handler replace it with the default one (as well as logging the exception).

Since there is no official console/scripting tool to modify settings, creating the file manually is the only option.
Reply With Quote
  #13  
Old 30.08.2019, 11:19
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 64,732
Default

Quote:
Originally Posted by darkdragon-001 View Post
With *old* value I mean the erroneous one from the config file, the one you try to cast but fail to do so. So you could just catch the exception and in the catch handler replace it with the default one (as well as logging the exception).
I've already answered to this

Quote:
I'm against auto replacing by default value if the application doesn't expect this. I've added auto conversion from string -> boolean/numbers and will also add optional *auto replace by default*
This will only lead to unpredictable behaviour. the *auto replace by default* is disabled by default
__________________
JD-Dev & Server-Admin
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 00:32.
Provided By AppWork GmbH | Privacy | Imprint
Parts of the Design are used from Kirsch designed by Andrew & Austin
Powered by vBulletin® Version 3.8.10 Beta 1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.