mbank-cli icon indicating copy to clipboard operation
mbank-cli copied to clipboard

Internal error: activate-profile: ambiguous profile name

Open netmaniac opened this issue 5 years ago • 9 comments

When I switch from business to personal profile I get error:

$ ./mbank-cli activate-profile personal
Internal error: activate-profile: ambiguous profile name at ./mbank-cli line 2682.
	main::do_activate_profile("args", ARRAY(0x55f247d0d420), "login", HASH(0x55f24805dc88)) called at ./mbank-cli line 3342
	main::main() called at ./mbank-cli line 3346

Switching from personal to business does work - if I log in via browser and switch profile to personale./mbank-cli list personal accounts, and then activate-profile business works as expected.

Non standard thing in my personal account is that I have access to two personal accounts - my own, and one with power of attorney.

netmaniac avatar Mar 01 '21 21:03 netmaniac

I guess this could be fixed in a similar way it was done for multiple bussiness profiles: b49e35d81916bef3a855d577c5886030b3fcc772

jwilk avatar Feb 24 '23 17:02 jwilk

@netmaniac, can you apply this patch:

diff --git a/mbank-cli b/mbank-cli
index 751fa30..a29744f 100755
--- a/mbank-cli
+++ b/mbank-cli
@@ -1493,4 +1493,5 @@ sub _extract_login_profiles
         my ($js) = ($content =~ m/^\s*Ebre[.]Venezia[.]ProfileData\s*=\s*([{].+[}]);\s*$/m)
             or next;
+        debug("profile data = $js");
         $js = unicode_to_bytes($js, 'UTF-8');
         my $json = decode_json($js, context => 'login.profiles.json');

then run mbank-cli --verbose, and paste the profile data it dumps? (Or send it by e-mail if there's anything confidential there.)

jwilk avatar Feb 27 '23 19:02 jwilk

Hello, Some time have passed :) but now I would like to try these feature again, but still is the same error. After applying patch (on current version from master cf1f9ac9e55101c849786401097ac73f301d97bd) output is as follow

./mbank-cli --config ~/.config/mbank-cli/config --verbose activate-profile "personal"
* selected command: activate-profile
* cookiejar = /home/viciu/mbank-cli/16678230.cookies
* GET https://online.mbank.pl/pl
* profile data = {"iProfiles":{"appURL":"#market/group/IO","active":false,"profiles":[{"profileCode":"L","active":false,"previouslyActive":false,"firmName":null},{"profileCode":"T","active":false,"previouslyActive":true,"firmName":null},{"profileCode":"*","active":false,"previouslyActive":false,"firmName":null}]},"fProfiles":{"appURL":"#market/group/BO","active":true,"profiles":[{"profileCode":"04275081","active":true,"previouslyActive":false,"firmName":"COMPANY NAME"}]}}
* logged in
Internal error: activate-profile: ambiguous profile name at ./mbank-cli line 2800.
	main::do_activate_profile("args", ARRAY(0x562fd4090320), "login", HASH(0x562fd43d8048)) called at ./mbank-cli line 3443
	main::main() called at ./mbank-cli line 3447
Please file a bug at <https://github.com/jwilk/mbank-cli/issues>.

I have only removed company name. As I have written earlier I have company account, my personal and some with with power of attorney.

netmaniac avatar Jan 30 '24 11:01 netmaniac

The interesting part pretty-printed:

[
  {
    "profileCode": "L",
    "active": false,
    "previouslyActive": false,
    "firmName": null
  },
  {
    "profileCode": "T",
    "active": false,
    "previouslyActive": true,
    "firmName": null
  },
  {
    "profileCode": "*",
    "active": false,
    "previouslyActive": false,
    "firmName": null
  }
]

The code T means (or at least used to mean back in 2015) "own products" (in Polish: "produkty własne"). This is the only profile I have here.

No idea what the other codes mean.

We need to invent some names for the profiles. I suppose we could go with personal/L, personal/T etc., and leave figuring out what they mean as an exercise to the users. Not ideal, but certainly better than an internal error. :)

jwilk avatar Jan 30 '24 13:01 jwilk

I suppose we could go with personal/L, personal/T etc.

Implemented in c41e95ae1080a7430818fc22aeb8850f7946176d.

Let me know if it works for you.

Also let me know if you have better ideas how it should work. :)

jwilk avatar Jan 30 '24 19:01 jwilk

Will check later today, and regarding proflies - when I click in profile switcher on website I have four options (in Polish):

  • pełnomocnictwa
  • produkty własne
  • wszystkie produkty
  • profil firmowy COMPANY NAME

so I guess profile named "*" is "all products" from personal account.

netmaniac avatar Jan 31 '24 10:01 netmaniac

I found this in one of the JavaScript files:

switch (code) {
  case "L":
    return this._getIndyvidualProfileLabel("powerOfAttorneyProfile");
  case "T":
    return this._getIndyvidualProfileLabel("ownProductsProfile");
  case "*":
    return this._getIndyvidualProfileLabel("allProductsProfile");
  default:
    return this._getLiteral("companyProfileLabel");
}

jwilk avatar Feb 01 '24 14:02 jwilk

Works for me. Thank You.

netmaniac avatar Feb 08 '24 21:02 netmaniac