I got the error message below when performing a feature upgrade on a web-scoped feature:
Unable to access web scoped feature (Id: 0257689c-9e69-4700-a169-004f648d0924) because it references a non-existent or broken web (Id: 90d6c515-a4a7-4f25-a46d-d0505e54d973) on site ‘http://myServer’. Exception: System.ArgumentException: Value does not fall within the expected range.
at Microsoft.SharePoint.SPWebCollection.get_Item(Guid id)
at Microsoft.SharePoint.SPFeatureEnumeratorBase.GetCachedWeb(SPSite site, Guid webId, Guid featureId)
The error occurred when I attempted to enumerate the results of SPSite.QueryFeature(). The second Guid appears to be the ID of a web, but there were no webs in my site collection with that ID (hence the error). I noticed there were some deleted sites in the Site Collection Recycle Bin. I emptied this Recycle Bin and was then able to upgrade the feature successfully.
The feature I’m trying to upgrade was activated at these deleted sites (before they were deleted).