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

Additional bracket harms the parameter scope detection #403

Open
HolQue opened this issue Jan 3, 2025 · 5 comments
Open

Additional bracket harms the parameter scope detection #403

HolQue opened this issue Jan 3, 2025 · 5 comments

Comments

@HolQue
Copy link
Collaborator

HolQue commented Jan 3, 2025

Within a composite data structure I overwrite the value of an existing parameter "D" in this way:

${params}[1]['B'][0]['D'] : 11

This works like expected.

Now I make an error. I add an opening curly bracket after '{params}':

${params}{[1]['B'][0]['D'] : 11

The error message is:

'Missing scope for parameter '${D}'. To change the value of this parameter, an absolute path must be used: '${params}[1]['B'][0]['D']' or '${params.1.B.0.D}'.'

Of course, the expression on the left hand side of the colon is invalid now. But the error message is much far away from reality.

Intuitively I would expect a syntax error. A detailed statement like a missing scope cannot be given in this case, because such a
statement would require a valid syntax of the expression.

Do we have any valid case where a parameter (${params}) can be followed by an opened curly bracket? I don't think so.

Please try to rework the error handling in such cases.

@HolQue
Copy link
Collaborator Author

HolQue commented Jan 3, 2025

Addendum:

I move the additional opening curly bracket to the right (now placed between [1] and ['B']):

${params}[1]{['B'][0]['D'] : 11,

This is accepted. No error. Value of 'D' is 11.

But expected is a syntax error.

@HolQue
Copy link
Collaborator Author

HolQue commented Jan 3, 2025

Addendum:

Again I move the additional opening curly bracket to the right (now placed between ['D' and ]):

"D" : 5,
${params}[1]['B'][0]['D'{] : 11,

Now that looks like the bracket belongs to the key name.

Result:

'D' has still value 5.
A new parameter with name '${params}[1]['B'][0]['D'{]' has value 11.

Issues:

  • The dollar operator expression is not resolved.
  • 'D'{ is not a valid name

Two possibilities to react:

  1. We accept 'D'{ to be a name. Then this should cause a naming convention violation because this name is invalid.
  2. We give the JSON syntax a higher priority. Curly brackets are part of the JSON syntax - and they are not expected at such a position (inside square brackets). Therefore this should cause a syntax error.

The same with an opening square bracket:

${params}[1]['B'][0]['D'[] : 11,

Result:

'Invalid key name: "${params}[1]['B'][0]['D'[]". A pair of square brackets is empty!!!'

Yes, the key name is invalid. But the second part of the error message also. The empty square brackets error is a misdiagnosis and does not fit to the first part of the error message.

@HolQue
Copy link
Collaborator Author

HolQue commented Jan 3, 2025

In general: The detection of additional brackets at invalid positions within expressions should be strengthened.

@HolQue
Copy link
Collaborator Author

HolQue commented Jan 3, 2025

Full example:

"C"  : 1,
"params" : [
              2,
              {"A" : 3,
               "B" : [
                        {
                           "C" : 4,
                           ${params.1.B.0.C]} : 10,
                           "D" : 5,
                           ${params}[1]['B'][0]['D'] : 11,
                           "E" : ["020", {"021" : "022"}],
                           "F" : {"023" : ["024", "025"]}
                        },
                        6
                     ]
              },
              7
           ]

Result:

Error: 'Invalid key name: "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""$""{""p""a""r""a""m""s"".""1"".""B"".""0"".""C""]""}"". Key names have to start with a letter, digit or underscore.'!

@HolQue
Copy link
Collaborator Author

HolQue commented Jan 3, 2025

Another invalid combination (again missing scope):

$${params.1.B.0.C} : 10,

Result:

'Missing scope for parameter '${C}'. To change the value of this parameter, an absolute path must be used: '${params}[1]['B'][0]['C']' or '${params.1.B.0.C}'.'

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