Skip to content

Align wildcard handling with up-spec and up-rust#317

Merged
PLeVasseur merged 10 commits intoeclipse-uprotocol:mainfrom
lukas-he:rework/313-align-wildcard-handling-with-spec-and-up-rust
Apr 29, 2025
Merged

Align wildcard handling with up-spec and up-rust#317
PLeVasseur merged 10 commits intoeclipse-uprotocol:mainfrom
lukas-he:rework/313-align-wildcard-handling-with-spec-and-up-rust

Conversation

@lukas-he
Copy link
Contributor

This PR closes #313.

@github-actions
Copy link

Code coverage report is ready! 📈

Copy link
Contributor

@PLeVasseur PLeVasseur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @lukas-he -- thanks for taking on updating this! I left a couple of comments to suggest a fix to match spec and an idea to align with up-rust.

bool uses_wildcards(const v1::UUri& uuri) {
constexpr auto LOWER_8_BIT_MASK = 0xFF;
bool has_wildcard_authority(const v1::UUri& uuri) {
return uuri.authority_name().find_first_of('*') != std::string::npos;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not equivalent to the spec, correct?

MAY have its authority_name set to the * (U+002A, Asterisk) character in order to match any (including no) authority.

So this code would call it wildcard authority if there's asterisk at any location in the string, right?

Can we make a simple equality comparison as is done in up-rust?

Copy link
Contributor Author

@lukas-he lukas-he Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I totally agree. We must consider the methods relying on that, i.e., the checks for valid RPC method/response.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm: this still needs updating, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends, if we say that these methods and responses do not allow any wildcards and a wildcard is given if verify_no_wildcards == false, then the corresponding modification is already made. If these methods require the "old" definition of authority wildcard, then we must change something.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see where the miscommunication may be creeping in.

In up-spec there's simply the concept of the authority being wildcard ("*") or not. There's no concept of an authority containing a wildcard ("otherstuff1*otherstuff2").

Note that you've updated the test here

uuri.set_authority_name("hello*");
was replaced with
uuri.set_authority_name("*");
which is correct

However, the code which checks for this looks for any instance of * in the authority string. I think we could change this:
return uuri.authority_name().find_first_of('*') != std::string::npos;
to a simple equality check between uuri.authority_name() and *.

In the spec's UUri Pattern Matching section for example:

def: matches_authority(candidate : UUri) : Boolean =
  self.authority_name = '*'
  or
  self.authority_name = candidate.authority_name

Hope that's clear! If not, let's hop on a call tomorrow to talk about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed that.

return uuri.resource_id() == LOWER_16_BIT_MASK;
}

bool uses_wildcards(const v1::UUri& uuri) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is somewhat the dual of the verify_no_wildcards() function within up-rust.

Perhaps we could remove uses_wildcards() and instead implement verify_no_wildcards() in up-cpp.

My thought process is that up-rust has been used more extensively and they chose this function instead, so aligning with that is probably more sensible.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also agree with that. I think that we can benefit if the concepts between up-cpp and up-rust don't differ that much.

EXPECT_FALSE(uses_wildcards(uuri));
}

{ // Change Authority name to "hello*" (Any)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay... I see why you implemented the wildcard authority check as you did now.

Seems there was a misunderstanding in up-cpp's implementation of the spec.

Please reference the comment I left up above and we can adjust the test code in tandem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A first suggestion for the tests in the next commit.

@github-actions
Copy link

Code coverage report is ready! 📈

@github-actions
Copy link

Code coverage report is ready! 📈

@github-actions
Copy link

Code coverage report is ready! 📈

@github-actions
Copy link

Code coverage report is ready! 📈

Copy link
Contributor

@PLeVasseur PLeVasseur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing this @lukas-he! I found a minor thing in a comment, but I'll just go ahead and apply the change and we can merge.

@github-actions
Copy link

Code coverage report is ready! 📈

@PLeVasseur PLeVasseur merged commit d720f57 into eclipse-uprotocol:main Apr 29, 2025
12 checks passed
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

Successfully merging this pull request may close these issues.

ue_id - service id vs instance id - wildcard handling

2 participants