Page MenuHomePhabricator

arc set-config: warn about unknown keys
ClosedPublic

Authored by avivey on Feb 15 2017, 1:21 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 11, 9:11 AM
Unknown Object (File)
Tue, Apr 9, 10:02 AM
Unknown Object (File)
Sat, Apr 6, 8:25 AM
Unknown Object (File)
Tue, Apr 2, 4:32 AM
Unknown Object (File)
Fri, Mar 29, 9:06 AM
Unknown Object (File)
Jan 30 2024, 7:47 AM
Unknown Object (File)
Jan 9 2024, 10:23 AM
Unknown Object (File)
Dec 28 2023, 4:40 PM

Details

Summary

See T12266. Warn when the user tries to set a value we will probably not read.

Test Plan

arc set-config foo bar, see fancy warning.

Diff Detail

Repository
rARC Arcanist
Branch
master
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 15636
Build 20639: Run Core Tests
Build 20638: arc lint + arc unit

Event Timeline

epriestley added inline comments.
src/workflow/ArcanistSetConfigWorkflow.php
79

I think you can make this translatable like this:

$warning = tsprintf(
  "**%s:** %s\n",
  pht('Warning'),
  pht('The configuration key ...'));
$console->writeErr("%s", $warning);
This revision is now accepted and ready to land.Feb 15 2017, 1:29 PM
This revision was automatically updated to reflect the committed changes.
joshuaspence added inline comments.
src/workflow/ArcanistSetConfigWorkflow.php
103

Hmm, now these strings aren't translatable.

I just assumed that writeOut() and friends are a flavor of pht()...

pht() is the only thing that does translations right now.

Omitting tsprintf() means that ANSI stuff won't be escaped. It doesn't really matter here since the string is controlled by the user, but there are quasi-attacks where users create a task or revision with a lot of terminal control characters in it so that arc list or arc todo or whatever potentially take over your terminal. tsprintf() avoids that.

The overall state of affairs isn't great right now since the minimal amount of code you need to write the word "hello" to stderr "correctly" (so it can be translated and is ANSI-safe) is this big mess:

$console->writeErr(
  "%s",
  tsprintf(
    "%s\n",
    pht('hello')));

This is pretty silly, but since pht() needs to be statically extracted we can't easily get rid of it, and merging the $console stuff with tsprintf() is sort of half-pointless if we don't go all the way to try to get rid of the pht() too.

There's also at least some kind of argument that "\n" and ANSI sequences shouldn't be translatable: at best, they're probably pretty confusing.