|
11 | 11 | import requests |
12 | 12 |
|
13 | 13 | from singer_sdk import typing as th # JSON Schema typing helpers |
| 14 | +from singer_sdk.exceptions import RetriableAPIError |
14 | 15 | from tap_adp.client import ADPStream, PaginatedADPStream |
15 | 16 |
|
16 | 17 | SCHEMAS_DIR = resources.files(__package__) / "schemas" |
@@ -261,16 +262,27 @@ def get_url_params( # noqa: PLR6301 |
261 | 262 | } |
262 | 263 |
|
263 | 264 | def validate_response(self, response: requests.Response) -> None: |
| 265 | + # Handle 404 errors with specific message about data loading |
| 266 | + if response.status_code == 404: |
| 267 | + response_json = response.json() |
| 268 | + if response_json.get("confirmMessage", {}).get("processMessages"): |
| 269 | + process_messages = response_json.get("confirmMessage", {}).get("processMessages") |
| 270 | + for process_message in process_messages: |
| 271 | + dev_message= process_message.get("developerMessage", {}).get("messageTxt", "") |
| 272 | + code_value = process_message.get("developerMessage", {}).get("codeValue") # Could use TURBOGEN000010 but this is such a weird code, I'm going with the message in case there's others that are close to this |
| 273 | + if "still loading the acc-all payroll data" in dev_message: |
| 274 | + raise RetriableAPIError(f"ADP API is still loading payroll data, will retry: {dev_message=}, {code_value=}", response) |
| 275 | + |
264 | 276 | if response.status_code == 400 and response.json().get("confirmMessage", {}).get("processMessages"): |
265 | 277 | process_messages = response.json().get("confirmMessage", {}).get("processMessages") |
266 | 278 | for process_message in process_messages: |
267 | 279 | dev_message = process_message["developerMessage"]["messageTxt"] |
268 | | - codeValue = process_message["developerMessage"]["codeValue"] |
| 280 | + code_value = process_message["developerMessage"]["codeValue"] |
269 | 281 | if dev_message == "Mass Processing is currently Disabled.": |
270 | 282 | exception_message = "Mass Processing is currently Disabled." |
271 | 283 | self.logger.warning(exception_message) |
272 | 284 | raise SkippableAPIError(exception_message) |
273 | | - if codeValue == "PAYGEN00030": #The payroll job id provided was in an invalid state (EDL, DAT, PVE, NER, EER, etc). |
| 285 | + if code_value == "PAYGEN00030": #The payroll job id provided was in an invalid state (EDL, DAT, PVE, NER, EER, etc). |
274 | 286 | exception_message = f"The payroll job id provided was in an invalid state ({dev_message})." |
275 | 287 | self.logger.warning(exception_message) |
276 | 288 | raise SkippableAPIError(exception_message) |
|
0 commit comments