Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

inconsistent variable or key not found #23

Closed
wants to merge 2 commits into from

Conversation

gimler
Copy link
Contributor

@gimler gimler commented Jan 23, 2020

The actual behaviour is inconsistent.

variable not exist key not exist
param exception -
array exception null
config null array last matching

I have added test for it. see also discussion #20

@edno edno added this to the 1.1.0 milestone Jan 24, 2020
@edno
Copy link
Owner

edno commented Jan 26, 2020

Hi @gimler

What should be the value for {{first_param}} and {{second_param}} when one variable was not set?

I think it would be more logical when the variable not exist. The argument is unchanged. For example

{{config:not_a_param}} would be {{config:not_a_param}} and not null

This way it is also easier to debug when a variable was not set.

I think you have a point here, and while adding features I remember that I had an issue while trying to make error handling consistent.
And, I like your initial suggestion to return the full keyword when a replacement cannot be found:

{{config:not_a_param}} would be {{config:not_a_param}} and not null

I was also thinking about potential breaking change introduced. But even if it breaks current error cases, that won't be a breaking change since tests will still fail.
Hence, it will still fulfil the use case that as a tester I expected my test to fail when the replacement pattern's parameter does not exist.

I would add also a debug message to make clear that the key/variable does not exist.

In that case, the above cases would be:

type keyword in code expected
variable {{ test }} test not defined {{ testt }}
array {{ test[999] }} test not defined {{ test[999] }}
array {{ test[999] }} array test exists but key 999 not defined {{ test[999] }}
config {{ config:test }} entry test not defined in config file {{ config:test }}
config {{ config:params:test }} entry params exists but sub entry test not defined in config file {{ config:params:test }}
config {{ config:test[42] }} entry (array) test exists but key 42 not defined in config file {{ config:test[42] }}

In that case, no exception would be raised for the above cases.

Is that aligned with your proposition?

edno added a commit that referenced this pull request Jan 30, 2020
Fix behaviour for invalid parameter (#23)
edno added a commit that referenced this pull request Jan 31, 2020
@edno
Copy link
Owner

edno commented Feb 4, 2020

Hi @gimler

I've prepared a new PR supporting this discussion: #26.

If you have time please let me know if it will fulfil your requirements.

edno added a commit that referenced this pull request Feb 9, 2020
2.0 - Support for handling invalid parameters (#23)
@edno
Copy link
Owner

edno commented Feb 9, 2020

Closed with #26

@edno edno closed this Feb 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants