We came across an issue where we were using Microsoft Dynamics AX 2009 SP1 (Application and Kernel build 5.0.1000.52) and we have setup a custom AIF endpoint for a specific company, in which we have selected options to propagate errors and automatically respond to errors. However we find in certain circumstances when a message fails processing the detailed errors are not always propagated back.
The issue was identified in the AifRequestProcessor class. When we are processing an inbound message we switch to the company in which the message belongs to using the changeCompany() statement, however if an error is generated we switch back to the original company and then the error response message cannot always find the data it needs to make as the response (as it belongs to another company).
This issue was first resolved in AX 2009 SP1 Hotfix Rollup 5 (recorded as KB number 982450). The changes were made in Classes\AifRequestProcessor