Page MenuHomePhabricator

[services] Tunnelbroker - Check for an empty string in ConfigManager
ClosedPublic

Authored by max on May 26 2022, 8:25 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Sep 16, 8:44 PM
Unknown Object (File)
Mon, Sep 2, 3:02 PM
Unknown Object (File)
Wed, Aug 28, 6:27 PM
Unknown Object (File)
Aug 19 2024, 1:15 AM
Unknown Object (File)
Aug 13 2024, 4:40 PM
Unknown Object (File)
Aug 13 2024, 4:39 PM
Unknown Object (File)
Aug 13 2024, 4:39 PM
Unknown Object (File)
Aug 13 2024, 4:39 PM

Details

Summary

This diff fixes a bug when the option in the config file provided, but has an empty value the app throws the following error:
what(): basic_string::_M_construct null not valid.
To fix this we will check the option value not to be empty or throw an appropriate error.

Linear task: ENG-1059

Test Plan

In the config file located at services/tunnelbroker/tunnelbroker.ini change the option value to an empty.
Run service using the command yarn run-tunnelbroker-service and expect the 'Error: config parameter X can not be empty' error.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

max held this revision as a draft.
max published this revision for review.May 26 2022, 8:28 AM
tomek requested changes to this revision.May 27 2022, 2:30 AM

Are we sure that empty parameter value is always invalid? Maybe this check should be made in a place where getParameter is called - and only in the places where empty string is invalid.

services/tunnelbroker/src/Tools/ConfigManager.cpp
97–102 ↗(On Diff #13147)

We can simplify the code

This revision now requires changes to proceed.May 27 2022, 2:30 AM

Reduce double variables map calling to one.

max marked an inline comment as done.
In D4137#117046, @palys-swm wrote:

Are we sure that empty parameter value is always invalid?

I think yes because there are only two options when the config parameter can be empty here:

  1. When the value is empty in the config ini file, for example:
[section]
value =

We don't want to allow that in ini file.

  1. When the default value constant is empty (in Constants.h).

There is a possibility that we will need an empty value in the future, but for now, we don't use any empty values in our constants and in default values in the configuration as well.
Also I don't imagine how we can use it in a such way.

services/tunnelbroker/src/Tools/ConfigManager.cpp
97–102 ↗(On Diff #13147)

We can simplify the code

Good optimization suggestion!
We don't need to call to variablesMap[param] twice here. I've updated on this.

This revision is now accepted and ready to land.May 31 2022, 2:57 AM