Page MenuHomePhorge

transaction.search: add auto-generated documentation for objectType and handle unmanaged exception
Needs ReviewPublic

Authored by valerio.bozzolan on Sat, May 3, 14:10.

Details

Summary

Finally we have some auto-generated documentation for the page /conduit/method/transaction.search/ about the supported values of objectType.
This is useful since we have 70+ of them, and they are totally obscure to newcomers (and us, core team, lol).

Transaction search new documentation table.png (1×1 px, 251 KB)

The already-existing exception messages now do not suggest anymore values that exist but are not supported (e.g. XACT).

Moreover, we handle an unmanaged exception in transaction.search, when the existing objectType is not supported (e.g. XACT).

Closes T16054
Closes T16057

Test Plan

Visit the page /conduit/method/transaction.search/ and enjoy the new amazing auto-generated table.

From the same page, visit the test form and set objectType = "XACT" and Call Method. You do not see anymore this confusing exception:

get_class() expects parameter 1 to be object, null given

Instead, you finally see this informative exception message (similar to the already-existing ones):

In call to "transaction.search", specified "objectType" ("XACT") is not supported because it does not implement "newObject()". Valid object types are: ABND, ADEV, AINT, ANAM, ANET, ASRV, DIFF, DREV, BOOK, DRYB, FBAK, FITV, HMBD, HMCP, HMCS, HMBB, HRUL, HWBH, HWBR, TASK, NUAI, NUAQ, NUAS, CDTL, FPRV, AUTH, CTNM, AMSG, APAS, AKEY, BDGE, CEVT, CEXP, CIMP, CONF, CONP, CDWN, DSHB, DSHP, PRTL, FORM, FILE, LEGD, MCRO, APPE, OASC, OPKG, PPAK, PPUB, PVER, PSTE, USER, BLOG, POST, PHRL, PANL, PCOL, PROJ, WTRG, CMIT, RIDT, REPO, RURI, POLL, SPCE, PSET, BULK, PVAR, MOCK, AEML, ACNT, CART, PMRC, PAYM, PHPR, PSUB, WIKI, ANSW, QUES.

Additionally, you can verify that the new documentation and the new methods in general are NOT called for normal valid API requests, so, not affecting production performance. An example of a valid request is: objectType = "TASK".

Diff Detail

Repository
rP Phorge
Branch
T16054
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 1929
Build 1929: arc lint + arc unit

Event Timeline

Should ideally use the same error message as in https://we.phorge.it/source/phorge/browse/master/src/applications/transactions/conduit/TransactionSearchConduitAPIMethod.php;4862eada5cd05236b81487b261668f2a2d72fad7$382-387 so one string less to translate.

Ironically though, that existing message will list XACT used to trigger this issue:

EXCEPTION: (Exception) In call to "transaction.search", specified "objectType" ("FOOB") is unknown. Valid object types are: ABND, ACNT, ADEV, AEML, AFTR, AINT, AINV, AKEY, AMSG, ANAM, ANET, ANSW, APAS, APPE, APPS, ASRV, ATOM, AUTH, BDGE, BLOG, BOOK, BULK, CART, CDTL, CDWN, CEVT, CEXP, CHAL, CHRG, CIMP, CMIT, CONF, CONP, CTNM, CXNV, DCNG, DIFF, DREV, DRYA, DRYB, DRYL, DRYO, DRYR, DSHB, DSHP, EADR, FBAK, FILE, FITV, FORM, FPRV, HLXS, HMBA, HMBB, HMBD, HMBT, HMCL, HMCP, HMCS, HRUL, HWBH, HWBR, LEGD, LEGS, MCRO, MOCK, MTAM, NUAC, NUAI, NUAQ, NUAS, OASA, OASC, OPKG, PANL, PAYM, PCOL, PDCT, PHPR, PHRL, PIMG, PLCY, PMRC, POLL, POST, PPAK, PPUB, PRCH, PROJ, PRTL, PSET, PSHE, PSHL, PSTE, PSUB, PULE, PVAR, PVER, QUES, REPO, RIDT, RREF, RURI, SPCE, SSSN, SYNE, TASK, TOKN, TRIG, USER, WIKI, WRDS, WTRG, XACT, XIDT, XOBJ, XUSR. at [<phorge>/src/applications/transactions/conduit/TransactionSearchConduitAPIMethod.php:382]

Should ideally use the same error message as in https://we.phorge.it/source/phorge/browse/master/src/applications/transactions/conduit/TransactionSearchConduitAPIMethod.php;4862eada5cd05236b81487b261668f2a2d72fad7$382-387 so one string less to translate.

Ironically though, that existing message will list XACT used to trigger this issue:

That already existing error message seems correct and it's about detecting a "known" type or not («is unknown»).

In our case, instead, the type exists, but «it is not supported» for that workflow.

Additionally, I don't know if we are able here to show the "supported types" in line 391 (that are less than the existing types, needed in the other if case).

P.S. - XACT exists, but it does not support the newObject():

https://we.phorge.it/source/phorge/browse/master/src/applications/transactions/phid/PhabricatorApplicationTransactionTransactionPHIDType.php;261fdca137e54b0c5b0e8e368530628f555210a6$13-16

So I think a new error message may make sense. But wait a bit since I may be able to show an even more-useful message. Wait some minutes lol

Generate a super-useful documentation table in Remarkup

valerio.bozzolan retitled this revision from transaction.search: handle unmanaged exception when objectType is not supported to transaction.search: add auto-generated documentation for objectType and handle unmanaged exception.Sun, May 4, 09:58
valerio.bozzolan edited the summary of this revision. (Show Details)
valerio.bozzolan edited the test plan for this revision. (Show Details)
valerio.bozzolan edited the summary of this revision. (Show Details)
valerio.bozzolan edited the test plan for this revision. (Show Details)
valerio.bozzolan edited the test plan for this revision. (Show Details)
valerio.bozzolan edited the test plan for this revision. (Show Details)
avivey added inline comments.
src/applications/transactions/conduit/TransactionSearchConduitAPIMethod.php
76–77

Is there a funny indentation here, or is that an artifact of the 2-up display?

394

"transaction.search" and objectTypeshould probably be extracted using %s`

430–432

I think we've settled for {$foo} only, and not $bar in strings.

463

array_keys($this->getSupportedObjectTypesAndName()) ?