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: https://github.com/react/react-native/pull/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
This commit is contained in:
Marc Rousavy authored and meta-codesync[bot] committed 2026-10-20 17:25:20 -07:00
1 parent 7b6516eb11
commit c7429b0e97
6 files changed
+20 -11

No files matched your search

@@ -8,12 +8,14 @@
#import <React/RCTInvalidating.h> #import <React/RCTInvalidating.h>
#import <React/RCTURLRequestHandler.h> #import <React/RCTURLRequestHandler.h>
NS_ASSUME_NONNULL_BEGIN
typedef NSURLSessionConfiguration *_Nullable (^NSURLSessionConfigurationProvider)(void); typedef NSURLSessionConfiguration *_Nullable (^NSURLSessionConfigurationProvider)(void);
/** /**
* The block provided via this function will provide the NSURLSessionConfiguration for all HTTP requests made by the * The block provided via this function will provide the NSURLSessionConfiguration for all HTTP requests made by the
* app. * app.
*/ */
RCT_EXTERN void RCTSetCustomNSURLSessionConfigurationProvider(NSURLSessionConfigurationProvider /*provider*/); RCT_EXTERN void RCTSetCustomNSURLSessionConfigurationProvider(NSURLSessionConfigurationProvider _Nullable /*provider*/);
typedef NSURLRequest *_Nullable (^RCTHTTPRequestInterceptor)(NSURLRequest *request); typedef NSURLRequest *_Nullable (^RCTHTTPRequestInterceptor)(NSURLRequest *request);
/** /**
@@ -21,7 +23,7 @@ typedef NSURLRequest *_Nullable (^RCTHTTPRequestInterceptor)(NSURLRequest *reque
* they are sent. Return a modified request to override, or nil to use the * they are sent. Return a modified request to override, or nil to use the
* original request unchanged. * original request unchanged.
*/ */
RCT_EXTERN void RCTSetCustomHTTPRequestInterceptor(RCTHTTPRequestInterceptor /*interceptor*/); RCT_EXTERN void RCTSetCustomHTTPRequestInterceptor(RCTHTTPRequestInterceptor _Nullable /*interceptor*/);
/** /**
* This is the default RCTURLRequestHandler implementation for HTTP requests. * This is the default RCTURLRequestHandler implementation for HTTP requests.
@@ -29,3 +31,5 @@ RCT_EXTERN void RCTSetCustomHTTPRequestInterceptor(RCTHTTPRequestInterceptor /*i
@interface RCTHTTPRequestHandler : NSObject <RCTURLRequestHandler, RCTInvalidating> @interface RCTHTTPRequestHandler : NSObject <RCTURLRequestHandler, RCTInvalidating>
@end @end
NS_ASSUME_NONNULL_END
@@ -10,11 +10,13 @@
#import <React/RCTDefines.h> #import <React/RCTDefines.h>
#import <React/RCTMultipartStreamReader.h> #import <React/RCTMultipartStreamReader.h>
NS_ASSUME_NONNULL_BEGIN
typedef void (^RCTMultipartDataTaskCallback)( typedef void (^RCTMultipartDataTaskCallback)(
NSInteger statusCode, NSInteger statusCode,
NSDictionary *headers, NSDictionary *_Nullable headers,
NSData *content, NSData *_Nullable content,
NSError *error, NSError *_Nullable error,
BOOL done); BOOL done);
typedef NSURLRequest *_Nullable (^RCTMultipartDataTaskRequestInterceptor)(NSURLRequest *request); typedef NSURLRequest *_Nullable (^RCTMultipartDataTaskRequestInterceptor)(NSURLRequest *request);
@@ -23,14 +25,17 @@ typedef NSURLRequest *_Nullable (^RCTMultipartDataTaskRequestInterceptor)(NSURLR
* requests before they are sent. Return a modified request to override, or nil * requests before they are sent. Return a modified request to override, or nil
* to use the original request unchanged. * to use the original request unchanged.
*/ */
RCT_EXTERN void RCTSetCustomMultipartDataTaskRequestInterceptor(RCTMultipartDataTaskRequestInterceptor /*interceptor*/); RCT_EXTERN void RCTSetCustomMultipartDataTaskRequestInterceptor(
RCTMultipartDataTaskRequestInterceptor _Nullable /*interceptor*/);
@interface RCTMultipartDataTask : NSObject @interface RCTMultipartDataTask : NSObject
- (instancetype)initWithURL:(NSURL *)url - (instancetype)initWithURL:(NSURL *)url
partHandler:(RCTMultipartDataTaskCallback)partHandler partHandler:(RCTMultipartDataTaskCallback)partHandler
progressHandler:(RCTMultipartProgressCallback)progressHandler; progressHandler:(nullable RCTMultipartProgressCallback)progressHandler;
- (void)startTask; - (void)startTask;
@end @end
NS_ASSUME_NONNULL_END
@@ -1410,7 +1410,7 @@ interface RCTMountingManager : public NSObject {
} }
interface RCTMultipartDataTask : public NSObject { interface RCTMultipartDataTask : public NSObject {
public virtual instancetype initWithURL:partHandler:progressHandler:(NSURL* url, RCTMultipartDataTaskCallback partHandler, RCTMultipartProgressCallback progressHandler); public virtual instancetype initWithURL:partHandler:progressHandler:(NSURL* url, RCTMultipartDataTaskCallback partHandler, _Nullable RCTMultipartProgressCallback progressHandler);
public virtual void startTask(); public virtual void startTask();
} }
@@ -1453,7 +1453,7 @@ interface RCTMountingManager : public NSObject {
} }
interface RCTMultipartDataTask : public NSObject { interface RCTMultipartDataTask : public NSObject {
public virtual instancetype initWithURL:partHandler:progressHandler:(NSURL* url, RCTMultipartDataTaskCallback partHandler, RCTMultipartProgressCallback progressHandler); public virtual instancetype initWithURL:partHandler:progressHandler:(NSURL* url, RCTMultipartDataTaskCallback partHandler, _Nullable RCTMultipartProgressCallback progressHandler);
public virtual void startTask(); public virtual void startTask();
} }
@@ -1410,7 +1410,7 @@ interface RCTMountingManager : public NSObject {
} }
interface RCTMultipartDataTask : public NSObject { interface RCTMultipartDataTask : public NSObject {
public virtual instancetype initWithURL:partHandler:progressHandler:(NSURL* url, RCTMultipartDataTaskCallback partHandler, RCTMultipartProgressCallback progressHandler); public virtual instancetype initWithURL:partHandler:progressHandler:(NSURL* url, RCTMultipartDataTaskCallback partHandler, _Nullable RCTMultipartProgressCallback progressHandler);
public virtual void startTask(); public virtual void startTask();
} }
@@ -1410,7 +1410,7 @@ interface RCTMountingManager : public NSObject {
} }
interface RCTMultipartDataTask : public NSObject { interface RCTMultipartDataTask : public NSObject {
public virtual instancetype initWithURL:partHandler:progressHandler:(NSURL* url, RCTMultipartDataTaskCallback partHandler, RCTMultipartProgressCallback progressHandler); public virtual instancetype initWithURL:partHandler:progressHandler:(NSURL* url, RCTMultipartDataTaskCallback partHandler, _Nullable RCTMultipartProgressCallback progressHandler);
public virtual void startTask(); public virtual void startTask();
} }