Repository navigation
kvs: C++ key handling changes - #508
Conversation
License Check Results🚀 The license check job ran with the Bazel command: bazel run --lockfile_mode=error //:license-checkStatus: Click to expand output |
|
Documentation preview for this pull request is available at: |
97444b6 to
2191a8c
Compare
| :tags: inspected | ||
|
|
||
| The component shall encode each key as valid UTF-8. | ||
| The component shall encode each key as valid ASCII, compatible with UTF-8. |
There was a problem hiding this comment.
IMHO this contradicts to comp_req__kvs__key_naming (see line 30 ff of this file) it states keys that consist solely of alphanumeric characters, underscores, or dashes even not sure if alphanumeric is a exact statement ... still why should we limit us further then the json RFC it would allow keys like café_1 or 用户编号 which IMHO is fine? There is no restriction on the RFC on keys in the requirements of https://github.com/eclipse-score/baselibs/blob/main/score/json/docs/vajson/requirements/index.rst or in the generic json requirements? Also IMHO questionable why we limit us to dashes and underscores .. any technical reason?
There was a problem hiding this comment.
Okay, I went the other way - considering std::string an ASCII-encoded type, with an additional limitation being character subset.
Since std::string is encoding-agnostic then I can restore UTF-8 and simply expand unit tests to ensure it's working.
I don't really see the point of limiting the allowed characters either, but it's not always obvious which requirement is discussed and accepted, and which requirement is a candidate for a rewrite.
| :tags: inspected | ||
|
|
||
| The component shall limit the maximum length of a key to 32 bytes. | ||
| The component shall disallow empty keys and limit the maximum length of a key to 32 bytes. |
There was a problem hiding this comment.
Updating components requirements will need to be revisited after merging component requirements pr
2191a8c to
4af468d
Compare
|
|
||
| Component Requirements | ||
| ---------------------- | ||
|
|
There was a problem hiding this comment.
Key naming - characters should printable ASCII characters.
There was a problem hiding this comment.
Encoding shall be ASCII, compliant with UTF-8.
4af468d to
07dcf3a
Compare
- Add `InvalidKey` error, replacing `KeyTooLong`. - Allow only ASCII, UTF-8 compatible keys. - Allow only printable ASCII characters. - Allow only non-empty. - Update tests.
07dcf3a to
a42e46a
Compare
There was a problem hiding this comment.
🟢 Approval recommended
Validation, error handling, and tests consistently implement the revised requirements, with no unresolved findings.
0 open findings
What changed in this PR
Updates C++ KVS key validation to match revised requirements for non-empty, printable ASCII keys of at most 32 bytes.
Changes:
- Replaces
KeyTooLongwithInvalidKeyfor validation failures. - Applies validation when setting, retrieving, and loading keys.
- Updates requirements and tests, marking Rust rejection checks as expected failures.
| File | Description |
|---|---|
| score/kvs/tests/test_scenarios/cit/supported_datatypes.cpp | Exercises key validation and logs results. |
| score/kvs/tests/test_cases/tests/test_cit_supported_datatypes.py | Checks accepted and rejected keys. |
| score/kvs/rust_kvs/tests/test_scenarios/cit/supported_datatypes.rs | Aligns scenario inputs and logging. |
| score/kvs/kvs.hpp | Documents the updated error. |
| score/kvs/kvs.cpp | Implements shared key validation. |
| score/kvs/kvs_test.cpp | Covers invalid keys and boundaries. |
| score/kvs/kvs_error_test.cpp | Checks the new error message. |
| score/kvs/error.hpp | Defines InvalidKey. |
| score/kvs/error.cpp | Maps the new error message. |
| score/kvs/docs/requirements/index.rst | Revises key naming, encoding, and length requirements. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| } | ||
|
|
||
| /* Check if a key exists*/ | ||
| score::Result<bool> Kvs::key_exists(const std::string_view key) |
There was a problem hiding this comment.
should we validate the key in the follwoing functions : key_exists, get_default_value, reset_key, is_defaut_value and remove_key using is_key_valid ?
for ex :
if i called key_exist("") will returns false while get_value("") will return InvalidKey .
There was a problem hiding this comment.
Inconsistency inherited from previous change. I removed validation from get_value, so that key is only validated when it's being set. For other functions it can never happen and KeyNotFound is observed.
Key is validated only when set.
InvalidKeyerror, replacingKeyTooLong.Relates to #504