Opened 16 years ago

Closed 12 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 15 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 by zspitzer, 15 years ago

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 by tomfukushima, 15 years ago

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 by zspitzer, 15 years ago

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 by milicevic, 15 years ago

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 by zspitzer, 15 years ago

Priority: mediumhigh

in reply to:  4 comment:6 by milicevic, 15 years ago

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 by zspitzer, 14 years ago

Milestone: 2.1
Version: 2.0.22.1.0

comment:8 by zspitzer, 13 years ago

Version: 2.1.02.2.0

comment:9 by jng, 12 years ago

Milestone: 2.4

comment:10 by jng, 12 years ago

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.