Snowfakery icon indicating copy to clipboard operation
Snowfakery copied to clipboard

Exception thrown when using Counters.DateCounter

Open jorgesolebur opened this issue 3 years ago • 1 comments

Hello

I have the following recipe for a data import in Salesforce. I want to create 10 records with a createddate that increases 1 day for every record. Following the documentation this is the resulting YAML file:

- plugin: snowfakery.standard_plugins.Salesforce
- plugin: snowfakery.standard_plugins.Salesforce.SalesforceQuery
- plugin: snowfakery.standard_plugins.Counters
- var: EveryDay
  value:
    Counters.DateCounter:
      start_date: 2021-01-01
      step: +1d
- object: TR_Apex_Test_Run_Result__c
  nickname: org1
  count: 10
  just_once: True
  fields: 
    TR_Covered_Lines__c: 
      random_number: 
          min: 2000
          max: 2500
    TR_Org_ID__c: 1
    TR_Org_Wide_Coverage__c: 
      random_number: 
          min: 80
          max: 90
    TR_Outcome__c: 
      random_choice: 
          - choice:
              probability: 90%
              pick: Passed
          - choice:
              probability: 10%
              pick: Failed
    TR_Failing_Tests__c: 
      random_number: 
        min: 0
        max: 3
    TR_Passing_Tests__c: 
      random_number: 
        min: 190
        max: 200
    TR_Skipped_Tests__c: 
      random_number: 
        min: 0
        max: 3
    TR_Test_Execution_Time__c: 
      random_number: 
        min: 200000
        max: 270000
    TR_Test_Run_Coverage__c: 
      random_number:
          min: 75
          max: 90
    TR_Tests_Ran__c: ${{TR_Failing_Tests__c + TR_Passing_Tests__c + TR_Skipped_Tests__c}}
    TR_Total_Lines__c: ${{TR_Covered_Lines__c/TR_Test_Run_Coverage__c*100}}
    CreatedDate: ${{EveryDay.next}}

Then I execute it using Cumulus CI command:

cci task run snowfakery --recipe ./snowflake/testRunResults.yaml --working_directory ./tmp/ --ignore_row_errors True --drop_missing_schema True --org tracker-ci

The script throws an exception when trying to generate the fake data (it is not the import - because the fake local DB is empty). This is the exception thrown:

[05/17/22 11:17:54] Getting org info from Salesforce CLI for [email protected]                                                                 
[05/17/22 11:18:04] Beginning task: Snowfakery                                                                                                             
                    As user: [email protected]                                                                                                 
                    In org: 00D1X000000AZVQ                                                                                                                
                                                                                                                                                           
                    Working Directory tmp                                                                                                                  
                    Working directory is tmp                                                                                                               
[05/17/22 11:18:05] Beginning task: GenerateAndLoadDataFromYaml                                                                                            
                    As user: [email protected]                                                                                                 
                    In org: 00D1X000000AZVQ                                                                                                                
                                                                                                                                                           
                    Beginning task: GenerateDataFromYaml                                                                                                   
                                                                                                                                                           
                    Generating batch 0 with 1                                                                                                              
[05/17/22 11:18:06] Generated batch                                                                                                                        
[05/17/22 11:18:07] Beginning task: LoadData                                                                                                               
                    As user: [email protected]                                                                                                 
                    In org: 00D1X000000AZVQ                                                                                                                
                                                                                                                                                           
[05/17/22 11:18:10] Running step: Insert TR_Apex_Test_Run_Result__c                                                                                        
                    Creating DataOperationType.INSERT Operation for TR_Apex_Test_Run_Result__c using DataApi.SMART                                         
                    Prepared 10 rows for DataOperationType.INSERT to TR_Apex_Test_Run_Result__c.                                                           
[05/17/22 11:18:11] Error on record with id 1: JSON_PARSER_ERROR: Cannot deserialize instance of datetime from VALUE_STRING value <bound method            
                    DateCounter.next of <<class 'snowfakery.standard_plugins.Counters.DateCounter'> {'start': datetime.date(2021, 1, 1), 'step': 86400.0}>>
                    or request may be missing a required field at [Source: N/A; line: -1, column: -1][line:-1, column:-1] ()                               
                    Error on record with id 2: JSON_PARSER_ERROR: Cannot deserialize instance of datetime from VALUE_STRING value <bound method            
                    DateCounter.next of <<class 'snowfakery.standard_plugins.Counters.DateCounter'> {'start': datetime.date(2021, 1, 1), 'step': 86400.0}>>
                    or request may be missing a required field at [Source: N/A; line: -1, column: -1][line:-1, column:-1] ()                               
                    Error on record with id 3: JSON_PARSER_ERROR: Cannot deserialize instance of datetime from VALUE_STRING value <bound method            
                    DateCounter.next of <<class 'snowfakery.standard_plugins.Counters.DateCounter'> {'start': datetime.date(2021, 1, 1), 'step': 86400.0}>>
                    or request may be missing a required field at [Source: N/A; line: -1, column: -1][line:-1, column:-1] ()                               
                    Error on record with id 4: JSON_PARSER_ERROR: Cannot deserialize instance of datetime from VALUE_STRING value <bound method            
                    DateCounter.next of <<class 'snowfakery.standard_plugins.Counters.DateCounter'> {'start': datetime.date(2021, 1, 1), 'step': 86400.0}>>
                    or request may be missing a required field at [Source: N/A; line: -1, column: -1][line:-1, column:-1] ()                               
                    Error on record with id 5: JSON_PARSER_ERROR: Cannot deserialize instance of datetime from VALUE_STRING value <bound method            
                    DateCounter.next of <<class 'snowfakery.standard_plugins.Counters.DateCounter'> {'start': datetime.date(2021, 1, 1), 'step': 86400.0}>>
                    or request may be missing a required field at [Source: N/A; line: -1, column: -1][line:-1, column:-1] ()                               
                    Error on record with id 6: JSON_PARSER_ERROR: Cannot deserialize instance of datetime from VALUE_STRING value <bound method            
                    DateCounter.next of <<class 'snowfakery.standard_plugins.Counters.DateCounter'> {'start': datetime.date(2021, 1, 1), 'step': 86400.0}>>
                    or request may be missing a required field at [Source: N/A; line: -1, column: -1][line:-1, column:-1] ()                               
                    Error on record with id 7: JSON_PARSER_ERROR: Cannot deserialize instance of datetime from VALUE_STRING value <bound method            
                    DateCounter.next of <<class 'snowfakery.standard_plugins.Counters.DateCounter'> {'start': datetime.date(2021, 1, 1), 'step': 86400.0}>>
                    or request may be missing a required field at [Source: N/A; line: -1, column: -1][line:-1, column:-1] ()                               
                    Error on record with id 8: JSON_PARSER_ERROR: Cannot deserialize instance of datetime from VALUE_STRING value <bound method            
                    DateCounter.next of <<class 'snowfakery.standard_plugins.Counters.DateCounter'> {'start': datetime.date(2021, 1, 1), 'step': 86400.0}>>
                    or request may be missing a required field at [Source: N/A; line: -1, column: -1][line:-1, column:-1] ()                               
                    Error on record with id 9: JSON_PARSER_ERROR: Cannot deserialize instance of datetime from VALUE_STRING value <bound method            
                    DateCounter.next of <<class 'snowfakery.standard_plugins.Counters.DateCounter'> {'start': datetime.date(2021, 1, 1), 'step': 86400.0}>>
                    or request may be missing a required field at [Source: N/A; line: -1, column: -1][line:-1, column:-1] ()                               
                    Error on record with id 10: JSON_PARSER_ERROR: Cannot deserialize instance of datetime from VALUE_STRING value <bound method           
                    DateCounter.next of <<class 'snowfakery.standard_plugins.Counters.DateCounter'> {'start': datetime.date(2021, 1, 1), 'step': 86400.0}>>
                    or request may be missing a required field at [Source: N/A; line: -1, column: -1][line:-1, column:-1] ()                               
                                                                                                                                                           
                     == Results ==                                                                                                                         
                           TR_Apex_Test_Run_Result__c: 0 successes, 10 errors                                                                              
                    ☃ Snowfakery created 1 iterations in 6s.       

It seems there is an error while trying to generate the next date. Can you please take a look?

jorgesolebur avatar May 17 '22 03:05 jorgesolebur

Hello! Is there anybody that can take a look?

Many thanks ;-)

jorgesolebur avatar May 29 '22 06:05 jorgesolebur