Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error messages (48) #402

Open
HolQue opened this issue Jan 2, 2025 · 2 comments
Open

Error messages (48) #402

HolQue opened this issue Jan 2, 2025 · 2 comments

Comments

@HolQue
Copy link
Collaborator

HolQue commented Jan 2, 2025

JSONP:

{
   "indexP" : 0,
   "keyP"   : "A",
   "dictP"  : {"A" : 0, "B" : 1},
   "listP"  : ["A", "B"],

   "params" : {"001" : "002",
               "003" : ["004", {"005" : "006",
                              "007" : ["008", ["009", "010"]],
                              ${keyP : ["012", {"013" : "014"}],
                              "015" : {"016" : ["017", "018"]},
                              "019" : {"020" : {"021" : "022"}}
                             }
                       ]
              }
}

Error message:

'Invalid key name: 'keyP : ["012", {"013" : "014"' in ${keyP : ["012", {"013" : "014"}. Key names are limited to letters, digits and the following characters: _ + - * /'

But the issue is not an invalid key name, it's a missing closed curly bracket.

I would prefer to have a "brackets mismatch" error message.

@HolQue
Copy link
Collaborator Author

HolQue commented Jan 3, 2025

Hmm, maybe a difficult thing. This is related to the order the different error detection mechanisms are executed within the JsonPreprocessor. I have the following in my mind: Before you check a key name against a naming convention you need to identify the name. This requires a corresponding closing curly bracket for every opening curly bracket (together with the dollar operator). In case of a closing bracket is missing, you cannot identify the name. Because you do not know where the name ends. This is a syntax error. In this case a statement about the validity of the key name makes no sense (and is also misleading for users).

But there is a closing curly bracket, but this belongs to an inline dictionary: {"013" : "014"}. Is it possible to detect this?

@HolQue
Copy link
Collaborator Author

HolQue commented Jan 3, 2025

Hi Son,

another idea. This is the critical line:

${keyP : ["012", {"013" : "014"}]

While scanning characters after ${, a colon is detected (before a closing curly bracket is detected).

We have two possibilities to react on that:

We assume we are still inside a key name, and we throw a naming convention error because of a colon is not allowed inside key names. This is how it is realized currently.

Or we interprete a colon as part of the JSON syntax with highest priority. We assume that a colon can never be a part of a key name. This rule would strongly require a closing curly bracket before the first colon in the example above. Because this bracket is missing, it is possible to detect a syntax error (instead of a naming convention violation).

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant