Skip to content

Commit c7429b0

Browse files
mrousavymeta-codesync[bot]
authored andcommitted
Fix nullability annotations in iOS networking headers (#59240)
Summary: Importing `RCTMultipartDataTask.h` and `RCTHTTPRequestHandler.h` produces nullability-completeness warnings because the headers mix annotated return values with unannotated pointers and blocks. Complete the annotations with `NS_ASSUME_NONNULL`, keeping optional configuration providers, interceptors, progress handlers and multipart callback payloads nullable. This matches the existing implementations, including clearing an interceptor with `nil` and reporting a failed multipart response without headers or content. ## Changelog: [IOS] [FIXED] - Fix missing nullability annotations in networking headers. Pull Request resolved: #59240 Test Plan: - Compiled a translation unit importing both headers with the Xcode 27.1 iOS Simulator SDK, ARC, blocks and `-Werror`. Passed in Objective-C and Objective-C++ modes. It also exercises clearing all three providers/interceptors with `nil`, returning `nil` from each interceptor, nullable multipart callback payloads and an absent progress callback. - The same header import on the original revision fails with nine `-Wnullability-completeness` errors. - Compiled `RCTMultipartDataTask.m` with `-fsyntax-only -Werror=nullability-completeness` against the same SDK. Passed. - Checked both changed headers with the repository's pinned clang-format 21.1.2 (`--dry-run --Werror`) and ran `git diff --check`. Passed. A full RNTester build was not run for this header-only change. Snapshot completion (local update): - Added the four generated ReactApple API snapshots from the CI artifact for PR head `151876277233befdbe7c0d9818039aa08ad15d1c`; verified the artifact SHA-256 against GitHub metadata. Imported headers and all prior snapshots match that revision. No header implementation or dependency changes. - The repository `validate_snapshots` comparison passes for all 12 generated views. `arc lint -a` reports no lint issues. - Full local `buck2 run fbsource//xplat/js/react-native-github/scripts/cxx-api:api-snapshot` could not regenerate: the existing codegen environment lacks `tinyglobby`. The updated files are exact generated CI output, not hand-edited snapshots. Reviewed By: christophpurrer Differential Revision: D126472293 Pulled By: javache fbshipit-source-id: 0c4f87e4d6f8c57f89f9e914d1c44a60802df1b6
1 parent 7b6516e commit c7429b0

6 files changed

Lines changed: 20 additions & 11 deletions

File tree

‎packages/react-native/Libraries/Network/RCTHTTPRequestHandler.h‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,28 @@
88
#import <React/RCTInvalidating.h>
99
#import <React/RCTURLRequestHandler.h>
1010

11+
NS_ASSUME_NONNULL_BEGIN
12+
1113
typedef NSURLSessionConfiguration *_Nullable (^NSURLSessionConfigurationProvider)(void);
1214
/**
1315
* The block provided via this function will provide the NSURLSessionConfiguration for all HTTP requests made by the
1416
* app.
1517
*/
16-
RCT_EXTERN void RCTSetCustomNSURLSessionConfigurationProvider(NSURLSessionConfigurationProvider /*provider*/);
18+
RCT_EXTERN void RCTSetCustomNSURLSessionConfigurationProvider(NSURLSessionConfigurationProvider _Nullable /*provider*/);
1719

1820
typedef NSURLRequest *_Nullable (^RCTHTTPRequestInterceptor)(NSURLRequest *request);
1921
/**
2022
* The block provided via this function can inspect/modify HTTP requests before
2123
* they are sent. Return a modified request to override, or nil to use the
2224
* original request unchanged.
2325
*/
24-
RCT_EXTERN void RCTSetCustomHTTPRequestInterceptor(RCTHTTPRequestInterceptor /*interceptor*/);
26+
RCT_EXTERN void RCTSetCustomHTTPRequestInterceptor(RCTHTTPRequestInterceptor _Nullable /*interceptor*/);
2527

2628
/**
2729
* This is the default RCTURLRequestHandler implementation for HTTP requests.
2830
*/
2931
@interface RCTHTTPRequestHandler : NSObject <RCTURLRequestHandler, RCTInvalidating>
3032

3133
@end
34+
35+
NS_ASSUME_NONNULL_END

‎packages/react-native/React/Base/RCTMultipartDataTask.h‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
#import <React/RCTDefines.h>
1111
#import <React/RCTMultipartStreamReader.h>
1212

13+
NS_ASSUME_NONNULL_BEGIN
14+
1315
typedef void (^RCTMultipartDataTaskCallback)(
1416
NSInteger statusCode,
15-
NSDictionary *headers,
16-
NSData *content,
17-
NSError *error,
17+
NSDictionary *_Nullable headers,
18+
NSData *_Nullable content,
19+
NSError *_Nullable error,
1820
BOOL done);
1921

2022
typedef NSURLRequest *_Nullable (^RCTMultipartDataTaskRequestInterceptor)(NSURLRequest *request);
@@ -23,14 +25,17 @@ typedef NSURLRequest *_Nullable (^RCTMultipartDataTaskRequestInterceptor)(NSURLR
2325
* requests before they are sent. Return a modified request to override, or nil
2426
* to use the original request unchanged.
2527
*/
26-
RCT_EXTERN void RCTSetCustomMultipartDataTaskRequestInterceptor(RCTMultipartDataTaskRequestInterceptor /*interceptor*/);
28+
RCT_EXTERN void RCTSetCustomMultipartDataTaskRequestInterceptor(
29+
RCTMultipartDataTaskRequestInterceptor _Nullable /*interceptor*/);
2730

2831
@interface RCTMultipartDataTask : NSObject
2932

3033
- (instancetype)initWithURL:(NSURL *)url
3134
partHandler:(RCTMultipartDataTaskCallback)partHandler
32-
progressHandler:(RCTMultipartProgressCallback)progressHandler;
35+
progressHandler:(nullable RCTMultipartProgressCallback)progressHandler;
3336

3437
- (void)startTask;
3538

3639
@end
40+
41+
NS_ASSUME_NONNULL_END

‎scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,7 @@ interface RCTMountingManager : public NSObject {
14101410
}
14111411

14121412
interface RCTMultipartDataTask : public NSObject {
1413-
public virtual instancetype initWithURL:partHandler:progressHandler:(NSURL* url, RCTMultipartDataTaskCallback partHandler, RCTMultipartProgressCallback progressHandler);
1413+
public virtual instancetype initWithURL:partHandler:progressHandler:(NSURL* url, RCTMultipartDataTaskCallback partHandler, _Nullable RCTMultipartProgressCallback progressHandler);
14141414
public virtual void startTask();
14151415
}
14161416

‎scripts/cxx-api/api-snapshots/ReactAppleFrameworksCxx.api‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1453,7 +1453,7 @@ interface RCTMountingManager : public NSObject {
14531453
}
14541454

14551455
interface RCTMultipartDataTask : public NSObject {
1456-
public virtual instancetype initWithURL:partHandler:progressHandler:(NSURL* url, RCTMultipartDataTaskCallback partHandler, RCTMultipartProgressCallback progressHandler);
1456+
public virtual instancetype initWithURL:partHandler:progressHandler:(NSURL* url, RCTMultipartDataTaskCallback partHandler, _Nullable RCTMultipartProgressCallback progressHandler);
14571457
public virtual void startTask();
14581458
}
14591459

‎scripts/cxx-api/api-snapshots/ReactAppleNewarchCxx.api‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,7 @@ interface RCTMountingManager : public NSObject {
14101410
}
14111411

14121412
interface RCTMultipartDataTask : public NSObject {
1413-
public virtual instancetype initWithURL:partHandler:progressHandler:(NSURL* url, RCTMultipartDataTaskCallback partHandler, RCTMultipartProgressCallback progressHandler);
1413+
public virtual instancetype initWithURL:partHandler:progressHandler:(NSURL* url, RCTMultipartDataTaskCallback partHandler, _Nullable RCTMultipartProgressCallback progressHandler);
14141414
public virtual void startTask();
14151415
}
14161416

‎scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,7 @@ interface RCTMountingManager : public NSObject {
14101410
}
14111411

14121412
interface RCTMultipartDataTask : public NSObject {
1413-
public virtual instancetype initWithURL:partHandler:progressHandler:(NSURL* url, RCTMultipartDataTaskCallback partHandler, RCTMultipartProgressCallback progressHandler);
1413+
public virtual instancetype initWithURL:partHandler:progressHandler:(NSURL* url, RCTMultipartDataTaskCallback partHandler, _Nullable RCTMultipartProgressCallback progressHandler);
14141414
public virtual void startTask();
14151415
}
14161416

0 commit comments

Comments
 (0)