Page MenuHomePhabricator

Generic types are not fully evaluated, wrongly returning errors
Open, HighPublicBUG REPORT

Description

Steps to replicate:

  • Define a generic type function that returns a type such as "Z8"
  • Use that generic type as the type of an argument to another function.

Example: https://gerrit.wikimedia.org/r/c/mediawiki/services/function-orchestrator/+/822057

What happens:

Error during evaluation "Could not dereference Z7K1". However by adding more logging (see https://phabricator.wikimedia.org/T314927) I see that the underlying issue is: 'Generic type function did not return a Z4: {"Z1K1":"Z9","Z9K1":"Z8"}'

What should have happened instead:

'{"Z1K1":"Z9","Z9K1":"Z8"}' is a reference that just needs to be recursively evaluated to a 'Z4'

Here is the culprit: https://github.com/wikimedia/mediawiki-services-function-orchestrator/blob/1c3ae6ee52209e7952747c1dcae5dfb27ff1843a/src/ZWrapper.js#L130. The resolve() call here does not resolve references.

Event Timeline

AAssaf updated the task description. (Show Details)
AAssaf added a subscriber: OZhang-WMF.
AAssaf renamed this task from Generic function types are not fully evaluated, wrongly returning errors to Generic types are not fully evaluated, wrongly returning errors.Aug 10 2022, 10:56 AM
This comment was removed by cmassaro.

There's a list of built-in types in function-schemata:javascript/src/utils.js (look for the isUserDefined) function.

utils should probably export a function like isType, which returns true if either

  • validatesAsType( object ).isValid() is true OR
  • validatesAsReference( object ).isValid() is true AND isUserDefined( object.Z9K1 ) is false

Is this still happening? @DVrandecic , feel free to assign this to me if it still needs to be looked at.

Hi and thank you for your interest! Please check thoroughly https://www.mediawiki.org/wiki/New_Developers (and all of its communication section!). The page covers how to get started, assigning tasks, task status, how to find a codebase, how to create patches, where to ask general development questions and where to get help with setup problems, and how to ask good questions. Thanks a lot! :)