Skip to content

Conversation

@alxkm
Copy link
Contributor

@alxkm alxkm commented Sep 4, 2025

This PR enhances test coverage for the Spring AI image observation components by adding comprehensive edge case validation tests across three key areas.

Changes Made

DefaultImageModelObservationConvention Tests
Added tests for handling edge cases in model and option parameters:

  • Null/Empty/Blank model handling - Validates proper behavior when model is not specified or contains only whitespace
  • Empty style and response format - Ensures empty optional parameters are correctly excluded from high cardinality metrics
  • Prompt without options - Tests the common scenario of simple prompts without additional configuration

ImageModelObservationContext Tests
Enhanced builder validation and error handling:

  • Builder with options - Validates context creation with ImageOptions
  • Comprehensive null/empty validation - Tests all variations of invalid provider values (null, empty string, blank/whitespace)
  • Multiple context independence - Ensures contexts created independently don't interfere with each other

FunctionToolCallback Tests
Added edge case for string input handling:

  • Empty string input - Validates proper handling of empty string parameters in tool callbacks

Improvements:
These tests improve robustness by:

  • Catching potential NPEs and validation issues early
  • Ensuring consistent behavior across edge cases
  • Providing clear error messages for invalid inputs
  • Covering common real-world scenarios that were previously untested

Signed-off-by: Oleksandr Klymenko <[email protected]>

Co-authored-by: Oleksandr Klymenko <[email protected]>
@sobychacko sobychacko added this to the 1.1.0.M1 milestone Sep 5, 2025
@sobychacko sobychacko merged commit 4ed5417 into spring-projects:main Sep 5, 2025
2 checks passed
SenreySong pushed a commit to SenreySong/spring-ai that referenced this pull request Sep 8, 2025
chedim pushed a commit to couchbaselabs/spring-ai that referenced this pull request Sep 19, 2025
Willam2004 pushed a commit to Willam2004/spring-ai that referenced this pull request Oct 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants