GnuCash
Contact   Instructions
Bug 796993 - Gnucash should warn the user in case of missing Alphavantage API key instead of silently failing
Summary: Gnucash should warn the user in case of missing Alphavantage API key instead ...
Status: RESOLVED FIXED
Alias: None
Product: GnuCash
Classification: Unclassified
Component: Currency and Commodity (show other bugs)
Version: unspecified
Hardware: PC Linux
: Normal minor
Target Milestone: ---
Assignee: core
QA Contact: core
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-28 09:48 EST by Bertrand Marc
Modified: 2020-06-13 15:50 EDT (History)
4 users (show)

See Also:


Attachments

Description Bertrand Marc 2018-12-28 09:48:40 EST
Dear Gnucash developers,

Following issue 796970, I believe it would be better for the user to be warned by Gnucash when the user tries to update currencies without providing an Alphavantage API key.

For now, Gnucash silently does nothing in this case, which is confusing for the user.

Wouldn't it be possible to catch the Finance::quote error that appears with the following?

$ gnc-fq-dump -v alphavantage T 
Finance::Quote fields Gnucash uses:
    symbol: T (deduced)          <=== required
      date: ** missing **        <=== recommended
  currency: ** missing **        <=== required
      last:                      <=\       
       nav:                      <=== one of these
     price:                      <=/        
  timezone:                      <=== optional

** This stock quote cannot be used by GnuCash!


All fields returned by Finance::Quote for stock T

stock           field  value
-----           -----  -----
T            errormsg: Expected ALPHAVANTAGE_API_KEY to be set; get an API key at https://www.alphavantage.co
T                last: **missing**
T                 nav: **missing**
T               price: **missing**
T             success: 0

Best,
Bertrand
Comment 1 Chris Good 2020-05-29 05:25:19 EDT
This would have to be done by a scheme programmer as gnc-fq-helper is called from src/gnucash/price-quotes.scm. Not me I'm afraid.
It would also have to cater for running 'gnucash --add-price-quotes=FILE' which does not have a gui.
Comment 2 John Ralls 2020-05-29 10:44:49 EDT
It's not possible for GnuCash to discover why a particular price request fails, Finance::Quote doesn't say and in most cases can't tell anyway because the quote supplier just returns an http error code.

What GnuCash could do is detect that the user is requesting an Alphavantage quote and that the key isn't set. That would be done in Perl for gnc-fq-dumper and in C for the Get Quotes button.
Comment 3 Frank H. Ellenberger 2020-05-29 11:56:56 EDT
The other way:
Before starting the request check for usage of sources Alphavantage or currency. If at least one is used, check for an existing Alphavantage key. If none is found throw an errormessage.
Comment 4 Chris Good 2020-05-30 06:18:20 EDT
I have added https://github.com/Gnucash/gnucash/pull/729 (master) which modifies gnc-fq-dump to give an err msg if ALPHAVANTAGE_API_KEY is needed but missing.

John Ralls, I wasn't sure if it would be acceptable to modify the C program to give a warning when the Get Quotes button is used as that would have to duplicate a lot of the processing done by price-quotes.scm.
Ideally, I think price-quotes.scm should be rewritten in C++ but that is beyond me. If you think the warning would be OK from the C program when Get Quotes button is used, I'll do that.
Comment 5 John Ralls 2020-05-30 11:49:45 EDT
Chris, if you think you can manage the price-source check in gnc_prices_dialog_get_quotes_clicked go right ahead.
Comment 6 John Ralls 2020-06-13 15:50:34 EDT
Chris's PR is merged for tomorrow's 3.905 release.

Note You need to log in before you can comment on or make changes to this bug.