In Progress [CPANEL-32041] cpanel api oddities

ca2236

Well-Known Member
Feb 2, 2018
228
22
18
Nebraska
cPanel Access Level
DataCenter Provider
Hello,

I'm trying to figure out what is going on here. There seems to be inconsistent data returned when calling this api and passing different values


for the below examples, Output 1 is different for Output 2. The has_backup changes when showing different wants. Additionally, I don't know why has_backup is even showing when I just say I want the domain (or domain,user) only
===============================================================================
#########
# Output 1 #
#########

# /usr/local/cpanel/bin/whmapi1 listaccts search=test.domain.com searchtype=domain want=domain
---
data:
acct:
-
domain: test.domain.com
has_backup: 0

#########
# Output 2 #
#########

# /usr/local/cpanel/bin/whmapi1 listaccts search=test.domain.com searchtype=domain want=domain,user
---
data:
acct:
-
domain: test.domain.com
has_backup: 1
user: testuser
===============================================================================
Thanks for your help :)
 
Last edited:

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,271
313
Houston
Yea, I'm able to replicate that inconsistency as well:

Code:
[[email protected] ipv4]# whmapi1 listaccts search=mydomain.us searchtype=domain want=domain
---
data:
  acct:
    -
      domain: mydomain.us
      has_backup: 0
    -
      domain: demo.mydomain.us
      has_backup: 0
    -
      domain: aliastest.mydomain.us
      has_backup: 0
metadata:
  command: listaccts
  reason: OK
  result: 1
  version: 1
Code:
[[email protected] ipv4]# whmapi1 listaccts search=mydomain.us searchtype=domain want=domain,user
---
data:
  acct:
    -
      domain: mydomain.us
      has_backup: 1
      user: lauren
    -
      domain: demo.mydomain.us
      has_backup: 1
      user: demomydomain
    -
      domain: aliastest.mydomain.us
      has_backup: 1
      user: aliasmydomain
metadata:
  command: listaccts
  reason: OK
  result: 1
  version: 1
Not only is the backup information inconsistent but I didn't ask for that parameter to be returned, as you noticed as well. I'll look through our cases to see if I can find anything on this and if not I'll get a new one opened for it and update this thread once I've done that. Thanks for pointing that out :)
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,271
313
Houston
Hi @ca2236

I've opened CPANEL-32041 - whmapi1 listaccts 'want' parameter includes has_backup return with inconsistent results for this issue. I'll update here with any further information on it as I get it.
 

ca2236

Well-Known Member
Feb 2, 2018
228
22
18
Nebraska
cPanel Access Level
DataCenter Provider
Thanks!

on a side note with this topic. Is there a way to only return a True/False answer for a pattern match? (or excluded metadata)?

also, another oddity with this: If I search for a domain that doesn't match, it only shows metadata, but I would expect result to be '0' for no matches, if this is what it means.

Please see below:

Note: I'm searching for a domain that doesn't exist on my server, yet the results show a value of '1' as if a match was found (as I understand it)

Code:
# /usr/local/cpanel/bin/whmapi1 listaccts search=test2.domain.com searchtype=domain want=domain
---
metadata:
  command: listaccts
  reason: OK
  result: 1
  version: 1

Subsequent tests are the same if want is removed. If I remove searchtype, I get all kinds of random output not matching the search parameter. Result always? seems to be '1' so maybe this doesn't mean how many results are found? This might be true since did a search for a domain that resulted in multiple matches and result is always '1'.

thanks for your help :)
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,271
313
Houston
on a side note with this topic. Is there a way to only return a True/False answer for a pattern match? (or excluded metadata)?
I think that depends on the return you're looking to get the True/False answer to.

Subsequent tests are the same if want is removed. If I remove searchtype, I get all kinds of random output not matching the search parameter. Result always? seems to be '1' so maybe this doesn't mean how many results are found? This might be true since did a search for a domain that resulted in multiple matches and result is always '1'.
I agree the output is confusing and seems inconsistent. I tried this as well with different parameters. You'd think that you'd return a 0 here for the parameters you've included in wants at the very least. I think the entire issue is related to the wants parameter and I'd like to see what development says about the case I opened as well. This thread is linked to it so they are able to reference this thread when necessary.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
6,810
895
313
cPanel Access Level
Root Administrator
I checked the case just now and I don't see any updates at this time. I did test this command on my end just now and I'm not seeing the has_backup option being listed:

Code:
# whmapi1 listaccts search=domain.com searchtype=domain want=domain
---
data:
  acct:
    -
      domain: domain.com
metadata:
  command: listaccts
  reason: OK
  result: 1
  version: 1
 
# whmapi1 listaccts search=domain.com searchtype=domain want=domain,user
---
data:
  acct:
    -
      domain: domain.com
      user: amps
metadata:
  command: listaccts
  reason: OK
  result: 1
  version: 1
That test was run on a version 98 system - can you let me know what version you're using at this time?
 

ca2236

Well-Known Member
Feb 2, 2018
228
22
18
Nebraska
cPanel Access Level
DataCenter Provider
Oops. I think I reopened the wrong bug, I can create a new ticket. I was thinking this was one where it shows a result=1 even if you use listaccts api and it returns no matches for domain. But the result still shows 1.

the result 1 could be true or number of results, so maybe I am misunderstanding that. But either way, should it be 0 (if it means true/false) for no results?