Skip to content

Conversation

@jack-berg
Copy link
Member

No description provided.

@jack-berg jack-berg requested a review from a team as a code owner February 6, 2025 16:08
*
* @param object the object to convert
* @return the equivalent {@link Value}
* @throws IllegalArgumentException if not able to convert the object to {@link Value}
Copy link
Member Author

Choose a reason for hiding this comment

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

Might want to throw a checked exception to more forcibly signal to callers that they need to handle this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Decided against this:

  • This method is analagous to jackson ObjectMapper#convertValue, which only throws a runtime exception. This API is quite popular and I've used it myself without issue for years, suggesting that a runtime exception is sufficient.
  • I'm not sure what checked exception would be most appropriate to throw. Probably some subclass of IOException, and we'd probably want to introduce our own dedicated exception. In contrast, IllegalArgumentException pretty perfectly describes the error and seems appropriate to throw.

@codecov
Copy link

codecov bot commented Feb 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.10%. Comparing base (92d23b2) to head (ff0044a).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7076      +/-   ##
============================================
+ Coverage     90.06%   90.10%   +0.03%     
- Complexity     7320     7335      +15     
============================================
  Files           825      825              
  Lines         22048    22081      +33     
  Branches       2179     2188       +9     
============================================
+ Hits          19857    19895      +38     
+ Misses         1511     1505       -6     
- Partials        680      681       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@jkwatson jkwatson left a comment

Choose a reason for hiding this comment

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

seems ok to me. Needs a rebase to get the apidiffs up to date, when you get a moment.

@trask
Copy link
Member

trask commented Sep 11, 2025

I'd suggest holding on this for a bit longer while we figure out the impact of extending attributes to support any value, just in case.

@jkwatson
Copy link
Contributor

I'd suggest holding on this for a bit longer while we figure out the impact of extending attributes to support any value, just in case.

should we move this to a Draft, then?

@jack-berg jack-berg marked this pull request as ready for review November 26, 2025 22:08
@jack-berg
Copy link
Member Author

Marking "Ready for review" now that #7814 is merged. Value seems likely to play a role in our complex attributes implementation, and having a generate convert method significantly improves the ergonomics.

for (Object entry : list) {
valueList.add(Value.convert(entry));
}
return Value.of(Collections.unmodifiableList(valueList));
Copy link
Member

Choose a reason for hiding this comment

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

Unmodifiable wrapper probably not needed since Value is already immutable?

}
valueMap.put((String) key, Value.convert(value));
});
return Value.of(Collections.unmodifiableMap(valueMap));
Copy link
Member

Choose a reason for hiding this comment

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

Same

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.

4 participants