Page MenuHomePhabricator

Generic types are not fully evaluated, wrongly returning errors
Closed, ResolvedPublicBUG 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! :)

Here's what I did:

  1. I created a Function that takes a string and returns a Type
  2. I created an Implementation for that function that is a composition and does Z801(Z6)
  3. I created another Function that takes a Type and returns a String
  4. I created a test that runs this new function on the function created in step 1 and expects a Z6K1 (see screenshot 1)
  5. I created an implementation for that function that is a composition and does Z803(Z3K3, Z811(Z803(Z4K2, K1))) (i.e. take the key id of the first of the list of keys of the given argument) (see screenshot 2)
  6. The test passes

Screenshot 2024-06-26 at 15.45.06.png (680×1 px, 62 KB)

Screenshot 2024-06-26 at 15.45.53.png (728×1 px, 80 KB)

Since the test passes that means that the issue as described here is resolved by now.

Version I tested it on: (df7160f) 16:27, 12 June 2024