@@ -104,6 +104,63 @@ def test_duplicate_conflict_uses_cached_polling(core, diff_scan_get_response):
104104 assert len (artifacts .added ) > 0
105105
106106
107+ def test_eager_create_artifacts_do_not_bypass_filtered_get (core , diff_scan_get_response ):
108+ """Unexpected create artifacts are ignored so the filtered GET remains canonical."""
109+ from types import SimpleNamespace
110+
111+ core .cli_config = SimpleNamespace (
112+ strict_blocking = False ,
113+ enable_gitlab_security = False ,
114+ generate_license = False ,
115+ legal_format = "socket" ,
116+ )
117+ core .sdk .diffscans .create_from_ids .return_value = {
118+ "diff_scan" : {
119+ "id" : "diff-scan-123" ,
120+ "artifacts" : diff_scan_get_response ["diff_scan" ]["artifacts" ],
121+ }
122+ }
123+
124+ core .get_diff_scan_artifacts ("head" , "new" )
125+
126+ core .sdk .diffscans .get .assert_called_once_with (
127+ core .config .org_slug ,
128+ "diff-scan-123" ,
129+ params = {"cached" : "true" , "omit_unchanged" : "true" },
130+ )
131+
132+
133+ def test_eager_list_artifacts_do_not_bypass_filtered_get (core , diff_scan_get_response ):
134+ """Unexpected duplicate-list artifacts cannot skip the filtered GET either."""
135+ from types import SimpleNamespace
136+
137+ core .cli_config = SimpleNamespace (
138+ strict_blocking = False ,
139+ enable_gitlab_security = False ,
140+ generate_license = False ,
141+ legal_format = "socket" ,
142+ )
143+ core .sdk .diffscans .create_from_ids .side_effect = APIFailure (
144+ "duplicate" , status_code = 409
145+ )
146+ core .sdk .diffscans .list .return_value = {
147+ "results" : [
148+ {
149+ "id" : "existing-diff-scan" ,
150+ "artifacts" : diff_scan_get_response ["diff_scan" ]["artifacts" ],
151+ }
152+ ],
153+ }
154+
155+ core .get_diff_scan_artifacts ("head" , "new" )
156+
157+ core .sdk .diffscans .get .assert_called_once_with (
158+ core .config .org_slug ,
159+ "existing-diff-scan" ,
160+ params = {"cached" : "true" , "omit_unchanged" : "true" },
161+ )
162+
163+
107164def test_fallback_to_streaming_diff_on_failure (core ):
108165 """If the diff-scans flow fails (e.g. token missing the diff-scans scopes),
109166 the comparison falls back to the legacy streaming diff transparently."""
0 commit comments