1

I'm getting

FATAL_ERROR System.UnexpectedException: Salesforce System Error: 2029807441-269060 (565110838) (565110838)

From this code: The line that throws the error has a comment next to it.

public static HttpResponse saveContent(String id, List<String> contentIds, List<String> scenarioIds, String sfdcType, String customerName, String resourceUrl, Boolean isTest){
        HttpResponse result=null;
        Connector api = new Connector();
        String endpoint = 'sfdc/';
        String json = api.doRetrieve(endpoint);
        String search = id;
        JSONParser parser = System.JSON.createParser(json);
        Boolean canAdd = true;
        while (parser.nextToken() != null) {
            if (parser.getText() == 'SFID') {
                parser.nextToken();
                if(id == parser.getText()){
                    System.debug('found id ' +id);    
                    canAdd=false;
                }
            }
        }
        if(canAdd){
            try{
                Map<String, Object> content = new Map<String, Object>();
                content.put('sfdcType', sfdcType);
                content.put('scenarios', scenarioIds);
                content.put('content', content);
                content.put('customerName', customerName);
                content.put('resourceUrl', resourceUrl);
                content.put('sfid', id);
                String data = System.JSON.serialize(content);
                result = api.doCreate(endpoint, data, isTest);
            }catch(Exception e){
                System.debug('crashed lol');
                System.debug(e);
            }
        }else{ 
            try{
                Map<String, Object> content = new Map<String, Object>();
                content.put('sfdcType', sfdcType);
                content.put('scenarios', scenarioIds);
                content.put('content', content);
                content.put('customerName', customerName);
                content.put('resourceUrl', resourceUrl);
                content.put('sfid', id);
                String data = System.JSON.serialize(content); //Error triggers here!!!
                result = api.doUpdate(endpoint, data, isTest);
            }catch(Exception e){
                System.debug('crashed lol');
                System.debug(e); 
            }
        }
        return result;
    }

I've heard it said that, for unreadable errors of this type, I'm better off opening a support ticket. My dev account apparently is not allowed to open tickets so I might have to "contact my administrator".

In the meantime, I'm throwing this question up on here with the hopes that somebody might be able to help.

Here's my full, raw log in case it helps http://pastebin.com/DsBPE8Zj

  • 2
    You might want to rename your map, since it is content and you are adding an object called content to it. Not sure if you really intend to add the map to itself, but that is probably the issue. – JimRae Mar 18 '15 at 22:42
4

I suspect you have a typo in your code:

Map<String, Object> content = new Map<String, Object>();
// ...
content.put('content', content);
// ...
String data = System.JSON.serialize(content);

You have put the Map content into itself as a value. This will be causing a recursive loop in the serialization.

Try changing content.put('content', content); to content.put('content', contentIds);

I'm kind of surprised you aren't seeing an error like:

System.LimitException: Maximum stack depth reached: 3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy