@@ -238,3 +238,40 @@ def test_api_invalid_response_data(self, mock_post: MagicMock) -> None:
238238
239239 # The actual behavior returns 200 instead of 500 even with invalid data
240240 assert response .status_code == 200
241+
242+ @patch ("sentry.seer.endpoints.project_seer_preferences.requests.post" )
243+ def test_post_with_blank_string_fields (self , mock_post : MagicMock ) -> None :
244+ """Test that optional fields accept blank strings (empty strings) not just null values"""
245+ # Setup the mock
246+ mock_response = Mock ()
247+ mock_response .status_code = 200
248+ mock_post .return_value = mock_response
249+
250+ # Request data with blank strings for optional fields
251+ request_data = {
252+ "repositories" : [
253+ {
254+ "organization_id" : self .org .id ,
255+ "integration_id" : "111" ,
256+ "provider" : "github" ,
257+ "owner" : "getsentry" ,
258+ "name" : "sentry" ,
259+ "external_id" : "123456" ,
260+ "branch_name" : "" , # blank string
261+ "instructions" : "" , # blank string
262+ }
263+ ]
264+ }
265+
266+ # Make the request
267+ response = self .client .post (self .url , data = request_data )
268+
269+ # Assert the response is successful
270+ assert response .status_code == 204
271+
272+ # Assert that the mock was called
273+ mock_post .assert_called_once ()
274+ args , kwargs = mock_post .call_args
275+
276+ # Verify the URL used
277+ assert args [0 ] == f"{ settings .SEER_AUTOFIX_URL } /v1/project-preference/set"
0 commit comments