Page MenuHomePhabricator

Snak formatter should handle mismatches between Snak's DataType and actual type of the DataValue
Closed, ResolvedPublic

Description

DispatchingValueFormatter::getFormatter first searches a PT formatter, then a VT formatter. Currently, most of the mappings in WikibaseValueFormatterBuilders are VT, which means there is no error for type mismatches if the property has one of those types.

I have no clue if we should move most of the VT to PT mappings or change the logic or whatever. JS does this correctly.


Version: master
Severity: normal
Whiteboard: u=dev c=backend p=5 s=2014-05-20

Details

Reference
bz63299

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 2:59 AM
bzimport set Reference to bz63299.
bzimport added a subscriber: Unknown Object (MLST).

I discussed this with Daniel Kinzler. The desired behavior is as following:

(in PropertyValueSnakFormatter::formatSnak)

  • Get data type for property
  • Get expected data value type for property data type
  • If expected data value type does not match actual data value type, add error to output (for widget html)
  • look up formatter based on property data type if expected data value type matches actual data value type
  • If no formatter found, look up formatter for actual data value type

Put together: Always format value, try to give error messages if there are mismatches.

(In reply to Adrian Lang from comment #1)

  • If expected data value type does not match actual data value type, add

error to output (for widget html)

Thinking about it, we'll need this also for wikitext output, for use on the client. So I suggest to make "include error info" a formatter option, so we can control whether error info is inlined in each context.

  • look up formatter based on property data type if expected data value type

matches actual data value type

  • If no formatter found, look up formatter for actual data value type

Put together: Always format value, try to give error messages if there are
mismatches.

Furthermore, if formatting of the DataValue for some other reason fails with an exception, the ValueSnakFormatter should catch that exception, log it (probably using wfWarn, not wfLogWarning), and optionally include it in the return value. In that case, use an ExceptionLocalizer to generate a human readable version of the error.

Change 131665 had a related patch set uploaded by Aude:
Handle mismatching data type / values in snak formatter

https://gerrit.wikimedia.org/r/131665

Change 131665 abandoned by Aude:
Handle mismatching data type / values in snak formatter

Reason:
will make more sense to sort out ExceptionLocalizer mess first and then split this in smaller patches

https://gerrit.wikimedia.org/r/131665

Change 133286 had a related patch set uploaded by Daniel Kinzler:
Handle DVs that mismatch a prop's expected type

https://gerrit.wikimedia.org/r/133286

Change 133286 merged by jenkins-bot:
Handle DVs that mismatch a prop's expected type

https://gerrit.wikimedia.org/r/133286