Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix retrieving properties by upstream ID and name #4432

Merged
merged 2 commits into from
Sep 10, 2024

Conversation

jhrozek
Copy link
Contributor

@jhrozek jhrozek commented Sep 10, 2024

Summary

  • Don't fail if lookupProperties include upstream ID but the entity does not - We recently enhanced the property service to include lookup by ID in the cache, which is great, but we didn't handle the case where the lookup properties included the upstream ID but the entity properties in the database did not. In that case we should fall back to looking the property by name.
  • Don't return provifv1.ErrEntityNotFound from the property service - It was irritating to have to handle two return codes. The caller really doesn't care why was the entity not found, just that it was not found. Let's conver the provider NotFound into service Not found so that the callers have one less error to handle.

Fixes #4431

Mark the type of change your PR introduces:

  • Bug fix (resolves an issue without affecting existing features)
  • Feature (adds new functionality without breaking changes)
  • Breaking change (may impact existing functionalities or require documentation updates)
  • Documentation (updates or additions to documentation)
  • Refactoring or test improvements (no bug fixes or new functionality)

Testing

I added a unit test. I need to do better testing, I'm just running out of time right now. I'll continue in the evening.

Review Checklist:

  • Reviewed my own code for quality and clarity.
  • Added comments to complex or tricky code sections.
  • Updated any affected documentation.
  • Included tests that validate the fix or feature.
  • Checked that related changes are merged.

…s not

We recently enhanced the property service to include lookup by ID in the
cache, which is great, but we didn't handle the case where the lookup
properties included the upstream ID but the entity properties in the
database did not. In that case we should fall back to looking the
property by name.
It was irritating to have to handle two return codes. The caller really
doesn't care why was the entity not found, just that it was not found.
Let's conver the provider NotFound into service Not found so that the
callers have one less error to handle.
@coveralls
Copy link

Coverage Status

coverage: 53.279% (-0.03%) from 53.312%
when pulling 3d2c994 on jhrozek:prop_by_upstream_fix
into cd940ff on stacklok:main.

@jhrozek
Copy link
Contributor Author

jhrozek commented Sep 10, 2024

I did some manual testing and the patch seems to indeed help.

@jhrozek jhrozek merged commit bcdd94e into mindersec:main Sep 10, 2024
22 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.

refreshing properties by both upstream ID and name doesn't work
3 participants