Skip to content

Adding exception type for empty callback functions (reopening of PR #301)#304

Merged
PLeVasseur merged 8 commits intoeclipse-uprotocol:mainfrom
lukas-he:bugfix/1.0.2/194-std-function-checks
Mar 7, 2025
Merged

Adding exception type for empty callback functions (reopening of PR #301)#304
PLeVasseur merged 8 commits intoeclipse-uprotocol:mainfrom
lukas-he:bugfix/1.0.2/194-std-function-checks

Conversation

@lukas-he
Copy link
Contributor

@lukas-he lukas-he commented Feb 11, 2025

Hello everyone,

As discussed with Greg yesterday, I am reopening a PR for Greg's bugfix contribution with PR #301 .

This exception will be thrown when an empty std::function is passed to
the callback connection module. Adding the type first so that tests can
be written.
Some L2 tests were asserting that the std::bad_function_call exception
should be thrown when a bad callback is called. We will be changing that
behavior so that the exception is thrown when the callback connection is
established, requiring updated test cases.
The CalleeHandle class is the "owner" of the callback function objects
associated with a callback connection. As such, it will check the
validity of those function objects and throw the EmptyFunctionObject
exception if either the callback or cleanup function is empty / invalid.
@lukas-he lukas-he changed the title Bugfix/1.0.2/194 std function checks Adding exception type for empty callback functions (reopening of PR #301) Feb 11, 2025
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.

Not much to say! LGTM. I learned a bit more C++ reading through here.

I saw that a couple of stages of CI fell over. @lukas-he -- would you like to investigate?

@lukas-he
Copy link
Contributor Author

I looked into the error and as far as I understand, the linting fails before actually linting, but when trying to install clang-tidy-12 see here. So we could go to a newer clang-tidy version. What do you think @PLeVasseur?

Co-authored-by: Pete LeVasseur <plevasseur@gmail.com>
@PLeVasseur
Copy link
Contributor

So we could go to a newer clang-tidy version.

Seems like a reasonable solution if the previous version we're using is not available and doesn't in-turn flag a bunch of more things to fix 😅

IIRC the default runner image is now Ubuntu 24.04.1, see here. Likely that version of clang-tidy may not be available.

If you find that updating clang-tidy flags a bunch of additional things to fix, one option is to use Ubuntu 22.04 for now. Then address the issues found by the new clang-tidy all in one PR. It's a thought!

@lukas-he
Copy link
Contributor Author

I went with clang-tidy 17. In my fork, the lint jobs worked so I integrated clang-tidy 17 here. @PLeVasseur could you please approve the CI here.

@PLeVasseur
Copy link
Contributor

@lukas-he -- is the idea that we get eclipse-uprotocol/up-conan-recipes#32 merged, then try to merge this one?

Wondering if there's anything we'd see that differs enough that up-cpp would remain broken? 🤔

If so, I suppose I'd like to have a set of patches / PRs which update things to a working state (with proof of this with a dummy PR branch), but land them one by one.

What do you think about this approach?

@lammjo
Copy link

lammjo commented Feb 25, 2025

So we could go to a newer clang-tidy version.

Seems like a reasonable solution if the previous version we're using is not available and doesn't in-turn flag a bunch of more things to fix 😅

IIRC the default runner image is now Ubuntu 24.04.1, see here. Likely that version of clang-tidy may not be available.

If you find that updating clang-tidy flags a bunch of additional things to fix, one option is to use Ubuntu 22.04 for now. Then address the issues found by the new clang-tidy all in one PR. It's a thought!

I ran both clang-tidy-12 and clang-tidy-18. Interestingly, the number of warnings is actually almost the same, but the linters detect very different issues (see the occurence counts below if you're curious). I suggest we go with your suggestion of pinning the Ubuntu 22.04 image in CI and using clang-tidy-12 for now.

clang-tidy-18-errors.txt
clang-tidy-12-errors.txt

@PLeVasseur
Copy link
Contributor

I suggest we go with your suggestion of pinning the Ubuntu 22.04 image in CI and using clang-tidy-12 for now.

Sounds good as a starting point.

@github-actions
Copy link

github-actions bot commented Mar 3, 2025

Code coverage report is ready! 📈

@PLeVasseur
Copy link
Contributor

@lukas-he -- can you double-check my question over here?

Long story short -- if #298 and #309 are one in the same, I'd say we go ahead and merge this as that had been our hand-wavey policy in the last week or so.

It heartens me to hear @lammjo mention that someone is working on #298 :)

@PLeVasseur
Copy link
Contributor

Merging this based on discussion with @lukas-he over Slack. Idea is to do #300, then #298 to resolve all clang-tidy issues in a couple of steps.

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 the contribution @lukas-he!

@PLeVasseur PLeVasseur merged commit 3c36e85 into eclipse-uprotocol:main Mar 7, 2025
11 of 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.

The callback connection module should check std::function parameters from outside for validity

4 participants