Page MenuHomePhabricator

Consider returning a result even if the fallback template does not apply
Closed, ResolvedPublic

Description

There may be cases where the fallback template does not apply. See T305168 for a possible workaround.

In these cases, the Web2Cit-Server would return an empty results array.

On the one hand, this would neglect the translation tests that may have been defined, making the Web2Cit-Monitor believe that no test has been defined for a specific target path.

On the other hand, because a result table would not be included in the html-format response, and because the "edit" link to edit the translation templates configuration file is included in the header of this table, this would leave users with no easy way to edit this configuration (in cases where doing so may be useful).

Consider returning an empty-outputs result in cases where no template applies for a given target.

Event Timeline

In addition, right now a path for which no applicable translation template is found, makes the Web2Cit-Monitor fail for the whole domain (T321093). (couldn't reproduce; see T317448#11683094)

diegodlh triaged this task as Medium priority.Oct 18 2022, 11:59 AM
This comment was removed by diegodlh.

On the other hand, because a result table would not be included in the html-format response, and because the "edit" link to edit the translation templates configuration file is included in the header of this table, this would leave users with no easy way to edit this configuration (in cases where doing so may be useful).

Also, debugging information does not seem to be showing in these cases. See for example: https://web2cit.toolforge.org/https://cidades.ibge.gov.br/brasil/pr/sao-joao-do-triunfo/pesquisa/38/46996

A user may want to fix a non-applicable fallback template by defining a custom template and they may have trouble debugging it because of this.

Because the debugging information is not part of the main block to which the result table belongs to, this probably should be addressed on a separate task.

There may be cases where the fallback template does not apply.

One possibility may be that Citoid returns a Web2Cit-invalid output for a given translation field. See T313236.

However, a far more common example may be a webpage returning a 404 error (pages no longer available, or invalid paths). This would return a 404 response from Citoid as well, which would cause the fallback template to be non-applicable.

Consider returning an empty-outputs result in cases where no template applies for a given target.

Make sure Web2Cit response continues to be 404 in these cases. See T305166.

Solving this issue, preferably before the Web2Cit session planned for the Wikimedia-Hackathon-2023, would greatly increase the usability of the monitor list during that session. Note that the monitor should be asked to re-run checks on all domains for changes to reflect immediately on the list.

no easy way to edit this configuration (in cases where doing so may be useful).

One of the cases why the fallback template does not apply may be because Citoid is returning a general error (see for example https://teara.govt.nz/en/biographies/4g2/galbraith-alexander). However, in these cases, there seems to be a bug causing the server to crash if a translation template has been configured; see T347508.

Because addressing the present task would provide users with an easy way to edit and create translation templates, it would important to address T347508 before to prevent server crashes.

Aklapper subscribed.

@diegodlh: Removing task assignee as this open task has been assigned for more than two years - See the email sent on 2025-05-22.
Please assign this task to yourself again if you still realistically [plan to] work on this task - it would be welcome!
If this task has been resolved in the meantime, or should not be worked on by anybody ("declined"), please update its task status via "Add Action… 🡒 Change Status".
Also see https://www.mediawiki.org/wiki/Bug_management/Assignee_cleanup for tips how to best manage your individual work in Phabricator. Thanks!

In addition, right now a path for which no applicable translation template is found, makes the Web2Cit-Monitor fail for the whole domain (T321093).

I created an example for this, using one of the URLs cited above:
https://web2cit.toolforge.org/translate?domain=cidades.ibge.gov.br&tests=true&sandbox=Diegodlh

A pattern is used to separate both paths. One of them is translated using a custom template. The other one fails translation because fallback template does not apply.

I haven't been able to reproduce the bug reported. That is, w2c-monitor doesn't seem to be failing for the whole domain just because no applicable template has been found for one of the paths.

In addition, I don't see why I said this was related to T321093, which is about empty target arrays. We don't get empty target arrays for domains where no applicable translation templates are found for one or more paths.

diegodlh claimed this task.

Fixed in 5ccd48b5. Pending deployment.

Fixed without changing Web2Cit-Core, by always calling w2c-core's Domain.translate() with onlyApplicable=false (i.e., not only when debug=true).

The performance impact of doing this is minimum: enriching an output with test results (in w2c-core's src/domain/domain.ts) takes less than 1 ms per template output:

const translationResults = templateOutputs.map((templateOutput) => {
  const scores = this.tests.score(templateOutput);
  const enrichedOutput = makeTranslationResult(
    templateOutput,
    scores,
    baseCitation
  );
  return enrichedOutput;
});

Data from non-applicable templates is then used to return a result for a non-applicable fallback template.

Data from non-applicable templates is then used to return a result for a non-applicable fallback template.

Made an additional change in Web2Cit-Server to not return field scores in these cases where field outputs have been ignored: 727096fb.

Updated the Docs/Server documentation to document both previous and this changes in the JSON output format: https://meta.wikimedia.org/w/index.php?title=Web2Cit/Docs/Server&diff=prev&oldid=30864630

On the one hand, this would neglect the translation tests that may have been defined, making the Web2Cit-Monitor believe that no test has been defined for a specific target path.

Additionally, updated Web2Cit-Monitor to better support Web2Cit Server returning a result with ignored outputs: 7ccc2ddd.

And made necessary changes to Web2Cit/results module to show expected field outputs in cases where no applicable template has been found: https://meta.wikimedia.org/w/index.php?title=Module:Web2Cit/results&diff=prev&oldid=30863914