Skip to content

Conversation

@AaronDDM
Copy link
Collaborator

@AaronDDM AaronDDM commented Jul 30, 2025

Changes

  • Upgraded OkHttp dependency from 3.14.5 to 4.12.0

License

I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner.

@playerzero-ai
Copy link

playerzero-ai bot commented Jul 30, 2025

Pull Request Summary

The pull request introduces several changes aimed at improving the codebase's reliability, readability, and compatibility with modern Kotlin and OkHttp practices. Key changes include:

  • Dependency Upgrade: Upgraded OkHttp from version 3.14.5 to 4.12.0, bringing in the latest features and improvements.

  • Type Safety Enhancements:

    • Explicitly specified Interceptor types in test setups across multiple test files to ensure type safety and improve test reliability.
    • Updated method calls to property access syntax for response.body and other properties, aligning with Kotlin conventions.
  • Test Suite Improvements:

    • Added new tests for Nylas API resources like Grants, Contacts, Scheduler, and Notetakers, enhancing test coverage.
    • Improved error handling and query parameter handling in tests to align with modern best practices.
  • Code Modernization:

    • Simplified property access and method calls in main code and tests to enhance readability and maintainability.
    • Replaced deprecated methods with modern Kotlin extension functions, such as using toMediaType() for MediaType conversion.
  • New Example:

    • Introduced a new Java example for handling large attachments, demonstrating the Nylas SDK's capabilities and providing educational content for developers.
  • Security and Logging:

    • Improved HTTP logging by ensuring sensitive headers are not logged and by enhancing the efficiency of logging operations.

These changes collectively aim to modernize the codebase, improve developer experience, and ensure the test suite remains robust and reliable.

Functional Tests

  • Verify that HTTP requests and responses are correctly logged without sensitive headers being exposed, ensuring security and privacy.
  • Test that the upgraded OkHttp library (version 4.12.0) integrates seamlessly with existing API requests and responses, maintaining expected functionality.
  • Ensure that all new tests for Nylas API resources (Grants, Contacts, Scheduler, Notetakers) pass successfully, confirming enhanced test coverage.
  • Check that the application handles response body decompression accurately, especially for gzipped responses, ensuring correct logging and data handling.
  • Validate that the type safety enhancements, such as specifying 'Interceptor' types, do not introduce any runtime errors or unexpected behaviors in the test suite.
  • Confirm that the code modernization efforts, including the use of Kotlin extension functions, do not affect the application's functionality and improve code readability.
  • Ensure that query parameter handling in API requests is robust, particularly with double query parameters, maintaining correct data conversion and request handling.
  • Verify that the streamlined request and response handling aligns with modern Kotlin conventions and does not disrupt existing workflows or introduce errors.

Files Changed

File Name Summary
src/test/kotlin/com/nylas/resources/SessionsTest.kt Specified Interceptor type in addInterceptor and body stubbing for better type safety in HTTP client mocks.
src/test/kotlin/com/nylas/resources/MessagesTests.kt Added Interceptor type in addInterceptor; accessed multipart size and body as properties for simpler code.
src/test/kotlin/com/nylas/resources/RedirectUriTests.kt Imported Interceptor; typed addInterceptor and accessed response.body as property for type safety and consistency.
src/test/kotlin/com/nylas/resources/BookingsTest.kt Typed addInterceptor with Interceptor; changed mockResponse.body() to property access for Kotlin style.
src/test/kotlin/com/nylas/NylasClientTest.kt Used Kotlin Mockito extensions; typed addInterceptor; added tests for new API resources; simplified body/header access; improved error and query param handling; standardized request tests.
src/main/kotlin/com/nylas/interceptors/HttpLoggingInterceptor.kt Simplified request/response property access; improved header logging; enhanced gzipped response handling; hid sensitive headers for security.
src/test/kotlin/com/nylas/resources/WebhooksTests.kt Imported Interceptor; typed addInterceptor and accessed body as property for test reliability.
src/test/kotlin/com/nylas/resources/ApplicationsTests.kt Imported Interceptor; typed addInterceptor and accessed response.body as property for type safety.
src/test/kotlin/com/nylas/resources/EventsTests.kt Typed addInterceptor and accessed response.body as property to improve mocking accuracy and type safety.
src/test/kotlin/com/nylas/resources/CredentialsTests.kt Imported Interceptor; typed addInterceptor; switched to property access for response.body.
examples/build.gradle.kts Added "Java-Large-Attachments" example to the listExamples task for demonstrating large attachment handling in Java.
src/test/kotlin/com/nylas/resources/NotetakersTests.kt Typed addInterceptor with Interceptor for clearer mocking in tests.
src/test/kotlin/com/nylas/resources/GrantsTests.kt Imported Interceptor; typed addInterceptor and accessed response.body as property for test type safety.
src/test/kotlin/com/nylas/resources/FoldersTests.kt Typed addInterceptor; changed mockResponse.body() to property access for Kotlin consistency.
examples/src/main/java/com/nylas/examples/LargeAttachmentsExample.java Added Java example showing sending large attachments with multipart handling, config loading, and error handling.
src/test/kotlin/com/nylas/resources/AuthTests.kt Imported Interceptor; used Kotlin toHttpUrl extension for URL creation; improved request interception in tests.
src/main/kotlin/com/nylas/util/JsonHelper.kt Replaced deprecated MediaType.parse with Kotlin extension toMediaType() for JSON media type definition.
src/test/kotlin/com/nylas/resources/AttachmentsTests.kt Imported Interceptor; typed addInterceptor; switched to property access for response.body for modern Kotlin style.
src/main/kotlin/com/nylas/interceptors/ContentHeadersInterceptor.kt Simplified URL path and request body/content type access using Kotlin property syntax for cleaner code.
src/test/kotlin/com/nylas/resources/DraftsTests.kt Typed addInterceptor; accessed MultipartBody size as property for clearer, idiomatic Kotlin code.
src/test/kotlin/com/nylas/resources/CalendarsTest.kt Typed addInterceptor; changed mockResponse.body() to property access for consistency.
src/test/kotlin/com/nylas/resources/ConfigurationsTest.kt Typed addInterceptor; switched to property access for mockResponse.body for readability.
src/test/kotlin/com/nylas/resources/ThreadsTests.kt Typed addInterceptor; changed mockResponse.body() to property access for Kotlin style.
src/test/kotlin/com/nylas/resources/ContactsTests.kt Typed addInterceptor with Interceptor; changed mockResponse.body() to property access for consistency.
src/main/kotlin/com/nylas/NylasClient.kt Used toHttpUrl() extension; simplified null checks and error handling; switched to property access for response code and headers.
examples/.env.example Added NYLAS_TEST_EMAIL environment variable for easier email testing configuration.
src/test/kotlin/com/nylas/resources/ConnectorsTests.kt Imported Interceptor; typed addInterceptor and accessed response.body as property for test safety.
src/test/kotlin/com/nylas/resources/SmartComposeTests.kt Imported Interceptor; typed addInterceptor and body calls for type safety and compatibility.
build.gradle.kts Upgraded OkHttp from 3.14.5 to 4.12.0 for improved HTTP client features.
src/main/kotlin/com/nylas/util/FileUtils.kt Added toMediaType() extension; replaced deprecated MediaType.parse() with it for attachment content types.

View more in PlayerZero
updated: Jul 31 @ 04:43 PM UTC

@AaronDDM AaronDDM force-pushed the adm/upgrade-okhttp-3-to-4 branch from 93802d3 to 24225cf Compare July 30, 2025 17:24
@AaronDDM AaronDDM force-pushed the adm/upgrade-okhttp-3-to-4 branch from 24225cf to 9530c1c Compare July 30, 2025 17:27
@AaronDDM AaronDDM force-pushed the adm/upgrade-okhttp-3-to-4 branch from 9530c1c to e029e2d Compare July 30, 2025 18:19
@AaronDDM AaronDDM force-pushed the adm/upgrade-okhttp-3-to-4 branch from e029e2d to 2564e9b Compare July 30, 2025 18:22
@AaronDDM AaronDDM force-pushed the adm/upgrade-okhttp-3-to-4 branch from 2564e9b to 1f52350 Compare July 30, 2025 19:50
@AaronDDM AaronDDM force-pushed the adm/upgrade-okhttp-3-to-4 branch from 1f52350 to 4906091 Compare July 30, 2025 20:06
@codecov-commenter
Copy link

codecov-commenter commented Jul 30, 2025

Codecov Report

❌ Patch coverage is 81.25000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.26%. Comparing base (454bcb2) to head (51a596f).

Files with missing lines Patch % Lines
src/main/kotlin/com/nylas/NylasClient.kt 78.57% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #290      +/-   ##
============================================
+ Coverage     80.57%   81.26%   +0.69%     
- Complexity      333      339       +6     
============================================
  Files            36       36              
  Lines          1014     1014              
  Branches         88       88              
============================================
+ Hits            817      824       +7     
+ Misses          138      132       -6     
+ Partials         59       58       -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

@ajay-k ajay-k left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@AaronDDM AaronDDM merged commit 2029a27 into main Jul 31, 2025
2 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.

5 participants