Opened 9 years ago

Closed 5 years ago

#649 closed defect (fixed)

FeatureService.UpdateFeatures doesn't log errors and reports them as succesful

Reported by: zspitzer Owned by:
Priority: high Milestone: 2.4
Component: Feature Service Version: 2.2.0
Severity: critical Keywords:
Cc: External ID:

Description

When doing an insert with FeatureService?.UpdateFeatures? it returne if there's a problem, it's returns as string GetPropertyType?(9) or on success as a featureReader GetPropertyType?(12).

When an error occurs, the access.log still logs it as successful rather than failed and the error is not logged to error.log

I triggered it by attempting to insert features into a non existent class

An exception occurred in FDO component. Item 'Rail3' not found in collection
  Exception occurred in method  MgServerUpdateFeatures.UpdateFeatures at line 97 in
 file  d:\buildforgeprojects\mapguide_open_source_v2.0\build_27.13\mgdev\server
\src\services\feature\ServerUpdateFeatures.cpp 

Using Mg 2.0.1 on XP

Attachments (1)

test-case-649-update-feature-errors-not-thrown.php (1.6 KB) - added by zspitzer 9 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 9 years ago by zspitzer

Severity: majorcritical
Summary: FeatureService.UpdateFeatures doesn't log errors correctlyFeatureService.UpdateFeatures doesn't log or throw errors

I am bumping this to critical, only because this is a potential dataloss bug

Most code (including samples which many users follow) will assume if an update/insert completes without throwing an error, it was successful, which is not true

comment:2 Changed 9 years ago by tomfukushima

Please add step-by-step instructions to recreate the problem; and it seems that a package and sample PHP script would also be required. Thanks, Tom

comment:3 Changed 9 years ago by zspitzer

Summary: FeatureService.UpdateFeatures doesn't log or throw errorsFeatureService.UpdateFeatures doesn't log errors and reports them as succesful
Version: 2.0.12.0.2

Ok, test case attached, it uses the a feature source from the Sheboygan Samples. It will fail to make any changes, due to the SDF being marked as READ ONLY and the FeatureClass? name is wrong ( should be Rail, is Rail3)

Simply run the script, tweaking the user/pass if required.

Current Behaviour: An error is returned in the result which must be manually inspected and the access.log reports the UpdateFeatures? operation as being Successful.

UpdateFeatures.1.0.0:3(Library://Samples/Sheboygan/Data/Rail.FeatureSource,MgFeatureCommandCollection,false,) Success

Expected Behaviour: An error should be thrown (to be caught), the UpdateFeatures? accesslog entry should be marked as Failure

UpdateFeatures.1.0.0:3(Library://Samples/Sheboygan/Data/Rail.FeatureSource,MgFeatureCommandCollection,false,) Failure

In addition the error message should be logged to error.log

An exception occurred in FDO component. Item 'Rail3' not found in collection
Exception occurred in method MgServerUpdateFeatures.UpdateFeatures at line 97 in 
file d:\buildforgeprojects\mapguide_open_source_v2.0\build_27.13\mgdev\server
\src\services\feature\ServerUpdateFeatures.cpp 

comment:4 Changed 9 years ago by milicevic

Hello,

i wolud like to report the same behaviour on deleting features. In fact, I don't get it, the code looks and works well, class name is just fine, filter condition also but no errors or exceptions has been thrown.

        string TIMgisUser = System.Configuration.ConfigurationManager.AppSettings["TIMgisUser"];
        MapGuideApi.MgInitializeWebTier(@"C:\program files\MapguideOpenSource2.0\WebServerExtensions\www\webconfig.ini");
        MgUserInformation userInfo = new MgUserInformation("Administrator", "" + System.Configuration.ConfigurationManager.AppSettings["mgP"] + "");
        MgSite site = new MgSite();
        site.Open(userInfo);
        String mgSessionId = site.CreateSession();

        MgUserInformation userInfoNew = new MgUserInformation(mgSessionId);
        MgSiteConnection siteConnection = new MgSiteConnection();
        siteConnection.Open(userInfoNew);

        MgResourceService resourceService = siteConnection.CreateService(MgServiceType.ResourceService) as MgResourceService;
        MgFeatureService featureService = siteConnection.CreateService(MgServiceType.FeatureService) as MgFeatureService;

        MgResourceIdentifier resId = new MgResourceIdentifier("Library://PROJEKTI/ZLZ/PODACI/DIONICE.FeatureSource");
        MgFeatureCommandCollection commands = new MgFeatureCommandCollection();

        string layerClassName = "DIONICE";
        
        MgDeleteFeatures deleteCmd = new MgDeleteFeatures(layerClassName , "(FeatId=1)");
        commands.Add(deleteCmd);

        featureService.UpdateFeatures(resId, commands, false);

comment:5 Changed 9 years ago by zspitzer

Priority: mediumhigh

comment:6 in reply to:  4 Changed 9 years ago by milicevic

Replying to milicevic:

Hello,

i wolud like to report the same behaviour on deleting features. In fact, I don't get it, the code looks and works well, class name is just fine, filter condition also but no errors or exceptions has been thrown.

        string TIMgisUser = System.Configuration.ConfigurationManager.AppSettings["TIMgisUser"];
        MapGuideApi.MgInitializeWebTier(@"C:\program files\MapguideOpenSource2.0\WebServerExtensions\www\webconfig.ini");
        MgUserInformation userInfo = new MgUserInformation("Administrator", "" + System.Configuration.ConfigurationManager.AppSettings["mgP"] + "");
        MgSite site = new MgSite();
        site.Open(userInfo);
        String mgSessionId = site.CreateSession();

        MgUserInformation userInfoNew = new MgUserInformation(mgSessionId);
        MgSiteConnection siteConnection = new MgSiteConnection();
        siteConnection.Open(userInfoNew);

        MgResourceService resourceService = siteConnection.CreateService(MgServiceType.ResourceService) as MgResourceService;
        MgFeatureService featureService = siteConnection.CreateService(MgServiceType.FeatureService) as MgFeatureService;

        MgResourceIdentifier resId = new MgResourceIdentifier("Library://PROJEKTI/ZLZ/PODACI/DIONICE.FeatureSource");
        MgFeatureCommandCollection commands = new MgFeatureCommandCollection();

        string layerClassName = "DIONICE";
        
        MgDeleteFeatures deleteCmd = new MgDeleteFeatures(layerClassName , "(FeatId=1)");
        commands.Add(deleteCmd);

        featureService.UpdateFeatures(resId, commands, false);

Hello,

I wolud like fill up my report. Thanks to Zac i have solved my problem. The reason was read only feature source.

comment:7 Changed 8 years ago by zspitzer

Milestone: 2.1
Version: 2.0.22.1.0

comment:8 Changed 7 years ago by zspitzer

Version: 2.1.02.2.0

comment:9 Changed 5 years ago by jng

Milestone: 2.4

comment:10 Changed 5 years ago by jng

Resolution: fixed
Status: newclosed

Fixed in 2.4 (r6846) and trunk (r6847)

Please note that the behaviour is still the same (ie. If MgPropertyCollection? contains MgStringProperty? instances, it means that particular command had an exception thrown).

The above changeset now properly logs such failures and documents this method behaviour in the API documentation.

Note: See TracTickets for help on using tickets.