netsuite icon indicating copy to clipboard operation
netsuite copied to clipboard

Get calls return item not found when the error is insufficient permission

Open Senjai opened this issue 7 years ago • 3 comments

Problem

When a user does not have permission to get a record, the gem reports an incorrect error

NetSuite::Records::CreditMemo.get(123) Will yield

NetSuite::RecordNotFound: NetSuite::Records::CreditMemo with OPTIONS={:internal_id=>123} could not be found

When the error via the logs is:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:
xsi="http://www.w3.org/2001/XMLSchema-instance">                                                                               
  <soapenv:Header>                                                                                                             
    <platformMsgs:documentInfo xmlns:platformMsgs="urn:messages_2016_2.platform.webservices.netsuite.com">                     
      <platformMsgs:nsId>WEBSERVICES_4548666_071320171044796155483003071_7fce118d7b34</platformMsgs:nsId>                      
    </platformMsgs:documentInfo>                                                                                               
  </soapenv:Header>                                                                                                            
  <soapenv:Body>                                                                                                               
    <getResponse xmlns="urn:messages_2016_2.platform.webservices.netsuite.com">                                                
      <readResponse>                                                                                                           
        <platformCore:status xmlns:platformCore="urn:core_2016_2.platform.webservices.netsuite.com" isSuccess="false">         
          <platformCore:statusDetail type="ERROR">                                                                             
            <platformCore:code>INSUFFICIENT_PERMISSION</platformCore:code>                                                     
            <platformCore:message>Permission Violation: You need  the 'Transactions -&gt; Credit Memo' permission to access thi
s page. Please contact your account administrator.</platformCore:message>                                                      
          </platformCore:statusDetail>                                                                                         
        </platformCore:status>                                                                                                 
      </readResponse>                                                                                                          
    </getResponse>                                                                                                             
  </soapenv:Body>                                                                                                              
</soapenv:Envelope>                                                                                                            

Expected Behavior

The gem raises a permission error instead.

Senjai avatar Jul 13 '17 23:07 Senjai

@Senjai good catch! Would you mind submitting a PR to fix this bug?

iloveitaly avatar Jul 14 '17 17:07 iloveitaly

@iloveitaly I'll try to find time to for sure. Can't promise anything immediate.

Senjai avatar Jul 17 '17 22:07 Senjai

Hey @iloveitaly Just following up on this. I won't have time to patch it. Apologies :( If anyone else wants to take it fly at 'er

Senjai avatar Feb 08 '18 18:02 Senjai