Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-intuitive error message when token is invalid #23

Open
perolavsvendsen opened this issue Nov 30, 2023 · 1 comment
Open

Non-intuitive error message when token is invalid #23

perolavsvendsen opened this issue Nov 30, 2023 · 1 comment

Comments

@perolavsvendsen
Copy link
Member

A user got the error printed below in stderr. When running sumo_login afterwards, she is taken through the device code flow process. So looks like her token was not valid. However, it is not possible to read from the error message that this is the issue.

Related to proxy...?

Any way we can/should detect this and provide clearer message?

<job>SUMO_UPLOAD</job>
<reason>Process exited with status code 1</reason>
<stderr>
WARNING:py.warnings:/prog/res/komodo/2023.11.00-py38-rhel7/root/lib/python3.8/site-packages/fmu/sumo/uploader/scripts/sumo_upload.py:119: UserWarning: Problem related to Sumo upload: Failed to acquire token by device flow. Err: {
    "error": "authorization_pending",
    "error_description": "AADSTS70016: OAuth 2.0 device flow error. Authorization is pending. Continue polling. Trace ID: b6744bd2-10a3-4de6-897e-dc931fb97b01 Correlation ID: 4cb01216-9de1-4c40-aa74-98b7a47e4081 Timestamp: 2023-11-29 13:49:27Z",
    "error_codes": [
        70016
    ],
    "timestamp": "2023-11-29 13:49:27Z",
    "trace_id": "b6744bd2-10a3-4de6-897e-dc931fb97b01",
    "correlation_id": "4cb01216-9de1-4c40-aa74-98b7a47e4081",
    "error_uri": "[https://login.microsoftonline.com/error?code=70016"](https://login.microsoftonline.com/error?code=70016%22)
}
  warnings.warn(
 
Traceback (most recent call last):
  File "/prog/res/komodo/2023.11.00-py38-rhel7/root/lib/python3.8/site-packages/fmu/sumo/uploader/scripts/sumo_upload.py", line 97, in sumo_upload_main
    e = uploader.CaseOnDisk(
  File "/prog/res/komodo/2023.11.00-py38-rhel7/root/lib/python3.8/site-packages/fmu/sumo/uploader/caseondisk.py", line 82, in __init__
    super().__init__(case_metadata, sumo_connection, verbosity)
  File "/prog/res/komodo/2023.11.00-py38-rhel7/root/lib/python3.8/site-packages/fmu/sumo/uploader/_sumocase.py", line 31, in __init__
    self._sumo_parent_id = self._get_sumo_parent_id()
  File "/prog/res/komodo/2023.11.00-py38-rhel7/root/lib/python3.8/site-packages/fmu/sumo/uploader/_sumocase.py", line 49, in _get_sumo_parent_id
    self.sumo_connection.api.get(f"/objects('{self._fmu_case_uuid}')")
  File "/prog/res/komodo/2023.11.00-py38-rhel7/root/lib/python3.8/site-packages/fmu/sumo/uploader/_connection.py", line 27, in api
    self._api = self._establish_connection()
  File "/prog/res/komodo/2023.11.00-py38-rhel7/root/lib/python3.8/site-packages/fmu/sumo/uploader/_connection.py", line 37, in _establish_connection
    return SumoClient(env=self.env, token=self.token)
  File "/prog/res/komodo/2023.11.00-py38-rhel7/root/lib/python3.8/site-packages/sumo/wrapper/sumo_client.py", line 70, in __init__
    self.auth = get_auth_provider(
  File "/prog/res/komodo/2023.11.00-py38-rhel7/root/lib/python3.8/site-packages/sumo/wrapper/_auth_provider.py", line 246, in get_auth_provider
    return AuthProviderDeviceCode(client_id, authority, resource_id)
  File "/prog/res/komodo/2023.11.00-py38-rhel7/root/lib/python3.8/site-packages/sumo/wrapper/_auth_provider.py", line 169, in __init__
    self.login()
  File "/prog/res/komodo/2023.11.00-py38-rhel7/root/lib/python3.8/site-packages/sumo/wrapper/_auth_provider.py", line 187, in login
    raise ValueError(
ValueError: Failed to acquire token by device flow. Err: {
    "error": "authorization_pending",
    "error_description": "AADSTS70016: OAuth 2.0 device flow error. Authorization is pending. Continue polling. Trace ID: b6744bd2-10a3-4de6-897e-dc931fb97b01 Correlation ID: 4cb01216-9de1-4c40-aa74-98b7a47e4081 Timestamp: 2023-11-29 13:49:27Z",
    "error_codes": [
        70016
    ],
    "timestamp": "2023-11-29 13:49:27Z",
    "trace_id": "b6744bd2-10a3-4de6-897e-dc931fb97b01",
    "correlation_id": "4cb01216-9de1-4c40-aa74-98b7a47e4081",
    "error_uri": "[https://login.microsoftonline.com/error?code=70016"](https://login.microsoftonline.com/error?code=70016%22)
}
 
During handling of the above exception, another exception occurred:
 
Traceback (most recent call last):
  File "/prog/res/komodo/2023.11.00-py38-rhel7/root/bin/sumo_upload", line 8, in <module>
    sys.exit(main())
  File "/prog/res/komodo/2023.11.00-py38-rhel7/root/lib/python3.8/site-packages/fmu/sumo/uploader/scripts/sumo_upload.py", line 68, in main
    sumo_upload_main(
  File "/prog/res/komodo/2023.11.00-py38-rhel7/root/lib/python3.8/site-packages/fmu/sumo/uploader/scripts/sumo_upload.py", line 121, in sumo_upload_main
    _sumo_logger = sumo_connection.api.getLogger("log_2_server_sumo_upload")
  File "/prog/res/komodo/2023.11.00-py38-rhel7/root/lib/python3.8/site-packages/fmu/sumo/uploader/_connection.py", line 27, in api
    self._api = self._establish_connection()
  File "/prog/res/komodo/2023.11.00-py38-rhel7/root/lib/python3.8/site-packages/fmu/sumo/uploader/_connection.py", line 37, in _establish_connection
    return SumoClient(env=self.env, token=self.token)
  File "/prog/res/komodo/2023.11.00-py38-rhel7/root/lib/python3.8/site-packages/sumo/wrapper/sumo_client.py", line 70, in __init__
    self.auth = get_auth_provider(
  File "/prog/res/komodo/2023.11.00-py38-rhel7/root/lib/python3.8/site-packages/sumo/wrapper/_auth_provider.py", line 246, in get_auth_provider
    return AuthProviderDeviceCode(client_id, authority, resource_id)
  File "/prog/res/komodo/2023.11.00-py38-rhel7/root/lib/python3.8/site-packages/sumo/wrapper/_auth_provider.py", line 169, in __init__
    self.login()
  File "/prog/res/komodo/2023.11.00-py38-rhel7/root/lib/python3.8/site-packages/sumo/wrapper/_auth_provider.py", line 187, in login
    raise ValueError(
ValueError: Failed to acquire token by device flow. Err: {
    "error": "authorization_pending",
    "error_description": "AADSTS70016: OAuth 2.0 device flow error. Authorization is pending. Continue polling. Trace ID: ec885ce6-3cea-44b1-ac31-1cf3837a8601 Correlation ID: c6ff96dc-b585-498c-a54b-e805c44d1265 Timestamp: 2023-11-29 14:04:31Z",
    "error_codes": [
        70016
    ],
    "timestamp": "2023-11-29 14:04:31Z",
    "trace_id": "ec885ce6-3cea-44b1-ac31-1cf3837a8601",
    "correlation_id": "c6ff96dc-b585-498c-a54b-e805c44d1265",
    "error_uri": "[https://login.microsoftonline.com/error?code=70016"](https://login.microsoftonline.com/error?code=70016%22)
}
</stderr>
<stderr_file>/scratch/johan_sverdrup/cdf/23p22p0pdev_faults/realization-2/pred/sumo_upload.stderr.121</stderr_file>
</error>
@roywilly
Copy link
Contributor

roywilly commented Dec 1, 2023

Error above is from STABLE / device-code flow.
Testing the same in 'komodo-testing' with the interactive login instead of the device-code login, i.e. removing ~/.sumo/* then running ert gui without actually logging in:

SUMO VERSIONS:
(kenv + 2023.12.rc4-py38-rhel7) bash-4.2$ pip list | grep -i sumo
fmu-sumo 1.0.3
fmu-sumo-sim2sumo 0.1.5
fmu-sumo-uploader 1.0.5
sumo-wrapper-python 1.0.5


IN THE CONSOLE where ert gui was run:

ert gui drogon_design.ert
Created directory: '/scratch/fmu/rowh/drogon-kmdotst-2--devdec-01/share/key_files'
Write ert config file path to file /scratch/fmu/rowh/drogon-kmdotst-2--devdec-01/share/key_files/ert_config_file.info
Created directory: '/scratch/fmu/rowh/drogon-kmdotst-2--devdec-01/share/observations/tables'
INFO:ErtScriptModule_4:Parsed /private/rowh/drogon/25oct/drogon_20230908_12-24/resmod/ff/23.1.1/ert/model/../input/observations/drogon_wbhp_rft_wct_gor_tracer_4d_plt.obs as an ERT observation file
INFO:ErtScriptModule_4:Observation dataframe validated
INFO:ErtScriptModule_4:Writing observations in YAML (webviz) format to file: /scratch/fmu/rowh/drogon-kmdotst-2--devdec-01/share/observations/tables/ert_observations.yml
INFO:ErtScriptModule_4:Writing observations in ResInsight format to CSV-file: /scratch/fmu/rowh/drogon-kmdotst-2--devdec-01/share/observations/tables/resinsight_observation.csv
OK - directory: '/scratch/fmu/rowh/drogon-kmdotst-2--devdec-01/share/observations' already exists
Copying directory structure /private/rowh/drogon/25oct/drogon_20230908_12-24/resmod/ff/23.1.1/ert/model/../../ert/input/observations/seismic -> /scratch/fmu/rowh/drogon-kmdotst-2--devdec-01/share/observations/

NOTE! Please login to Equinor Azure to enable Sumo access: we opened a login web-page for you in your browser.
You should complete your login within 7 minutes, that is before 13:00:54

Failed Equinor Azure login for Sumo access, one possible reason is timeout
The script 'WfCreateCaseMetadata' caused an error while running:
Client error '401 Unauthorized' for url 'https://main-sumo-dev.radix.equinor.com/api/v1/objects'
For more information check: https://httpstatuses.com/401
Traceback (most recent call last):
File "/prog/res/komodo/2023.12.rc4-py38-rhel7/root/lib64/python3.8/site-packages/ert/config/ert_script.py", line 99, in initializeAndRun
return self.run(*arguments)
File "/prog/res/komodo/2023.12.rc4-py38-rhel7/root/lib/python3.8/site-packages/fmu/dataio/scripts/create_case_metadata.py", line 81, in run
create_case_metadata_main(workflow_args)
File "/prog/res/komodo/2023.12.rc4-py38-rhel7/root/lib/python3.8/site-packages/fmu/dataio/scripts/create_case_metadata.py", line 90, in create_case_metadata_main
register_on_sumo(args, case_metadata_path)
File "/prog/res/komodo/2023.12.rc4-py38-rhel7/root/lib/python3.8/site-packages/fmu/dataio/scripts/create_case_metadata.py", line 137, in register_on_sumo
sumo_id = case.register()
File "/prog/res/komodo/2023.12.rc4-py38-rhel7/root/lib/python3.8/site-packages/fmu/sumo/uploader/caseondisk.py", line 192, in register
sumo_parent_id = self._upload_case_metadata(self.case_metadata)
File "/prog/res/komodo/2023.12.rc4-py38-rhel7/root/lib/python3.8/site-packages/fmu/sumo/uploader/caseondisk.py", line 202, in _upload_case_metadata
response = self.sumo_connection.api.post(
File "/prog/res/komodo/2023.12.rc4-py38-rhel7/root/lib/python3.8/site-packages/sumo/wrapper/_decorators.py", line 7, in wrapper
response.raise_for_status()
File "/prog/res/komodo/2023.12.rc4-py38-rhel7/root/lib/python3.8/site-packages/httpx/_models.py", line 749, in raise_for_status
raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '401 Unauthorized' for url 'https://main-sumo-dev.radix.equinor.com/api/v1/objects'
For more information check: https://httpstatuses.com/401

NOTE! Please login to Equinor Azure to enable Sumo access: we opened a login web-page for you in your browser.
You should complete your login within 7 minutes, that is before 13:08:14

Failed Equinor Azure login for Sumo access, one possible reason is timeout
CONFIG_PATH: fmuconfig/output/global_variables.yml


THEN IN THE SUMO_UPLOAD JOB IS LOOKS LIKE THIS:
WARNING:msal.oauth2cli.authcode:Found no browser in current environment. If this program is being run inside a container which has access to host network (i.e. started by docker run --net=host -it ...), you can use browser on host to visit the following link. Otherwise, this auth attempt would either timeout (current timeout setting is None) or be aborted by CTRL+C. Auth URI: https://login.microsoftonline.com/3aa4a235-b6e2-48d5-9195-7fcf05b459b0/oauth2/v2.0/authorize?client_id=1826bd7c-582f-4838-880d-5b4da5c3eea2&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A33252&scope=88d2b022-3539-4dda-9e66-853801334a86%2F.default+offline_access+offline_access+openid+profile&state=ogPifbCeBZMNSDAx&code_challenge=XEPfQQkFzH1A9Cj5R_QmKkIPb7QuLTWVdCBc8-ESExI&code_challenge_method=S256&nonce=47ed6b10f4eb003591f3aa957ca303d978047b31c890bfd2b6ada5466201bdde&client_info=1
INFO:fmu.sumo.uploader.caseondisk:Searching for files at share/results/polygons/*.csv
INFO:fmu.sumo.uploader.caseondisk:File appended: share/results/polygons/topvolon--gl_faultlines_extract_postprocess.csv
INFO:fmu.sumo.uploader.caseondisk:File appended: share/results/polygons/basevolantis--gl_faultlines_extract_postprocess.csv
INFO:fmu.sumo.uploader.caseondisk:File appended: share/results/polygons/topvolantis--gl_faultlines_extract_postprocess.csv
INFO:fmu.sumo.uploader.caseondisk:File appended: share/results/polygons/toptherys--gl_faultlines_extract_postprocess.csv
INFO:fmu.sumo.uploader.caseondisk:File appended: share/results/polygons/topvolantis--field_outline_fwl.csv
INFO:fmu.sumo.uploader.caseondisk:File appended: share/results/polygons/topvolantis--field_outline_goc.csv
INFO:fmu.sumo.uploader._sumocase:
6 files failed by Sumo. First 5 failed files:
INFO:fmu.sumo.uploader._sumocase:

INFO:fmu.sumo.uploader._sumocase:Filepath: /scratch/fmu/rowh/drogon-kmdotst-2--devdec-01/realization-0/iter-0/share/results/polygons/topvolon--gl_faultlines_extract_postprocess.csv
INFO:fmu.sumo.uploader._sumocase:Metadata: [401] Unauthorized
INFO:fmu.sumo.uploader._sumocase:Blob: [None] None
INFO:fmu.sumo.uploader._sumocase:

INFO:fmu.sumo.uploader._sumocase:Filepath: /scratch/fmu/rowh/drogon-kmdotst-2--devdec-01/realization-0/iter-0/share/results/polygons/basevolantis--gl_faultlines_extract_postprocess.csv
INFO:fmu.sumo.uploader._sumocase:Metadata: [401] Unauthorized
INFO:fmu.sumo.uploader._sumocase:Blob: [None] None
INFO:fmu.sumo.uploader._sumocase:

INFO:fmu.sumo.uploader._sumocase:Filepath: /scratch/fmu/rowh/drogon-kmdotst-2--devdec-01/realization-0/iter-0/share/results/polygons/topvolantis--gl_faultlines_extract_postprocess.csv
INFO:fmu.sumo.uploader._sumocase:Metadata: [401] Unauthorized
INFO:fmu.sumo.uploader._sumocase:Blob: [None] None
INFO:fmu.sumo.uploader._sumocase:

INFO:fmu.sumo.uploader._sumocase:Filepath: /scratch/fmu/rowh/drogon-kmdotst-2--devdec-01/realization-0/iter-0/share/results/polygons/toptherys--gl_faultlines_extract_postprocess.csv
INFO:fmu.sumo.uploader._sumocase:Metadata: [401] Unauthorized
INFO:fmu.sumo.uploader._sumocase:Blob: [None] None
INFO:fmu.sumo.uploader._sumocase:Summary:
INFO:fmu.sumo.uploader._sumocase:Total files count: 6
INFO:fmu.sumo.uploader._sumocase:OK: 0
INFO:fmu.sumo.uploader._sumocase:Failed: 6
INFO:fmu.sumo.uploader._sumocase:Rejected: 0
INFO:fmu.sumo.uploader._sumocase:Wall time: 0.8648761850199662 sec
INFO:fmu.sumo.uploader.caseondisk:Uploading parameters.txt
WARNING:py.warnings:/prog/res/komodo/2023.12.rc4-py38-rhel7/root/lib/python3.8/site-packages/fmu/sumo/uploader/scripts/sumo_upload.py:124: UserWarning: Problem related to Sumo upload: Client error '401 Unauthorized' for url 'https://main-sumo-dev.radix.equinor.com/api/v1/search?%24query=fmu.case.uuid%3Ab11279c7-d76f-4e05-a59a-6f1e4d9f71aa%20AND%20fmu.realization.uuid%3A383a298d-22fc-6d08-901b-20febed86ad1%20AND%20data.content%3Aparameters'
For more information check: https://httpstatuses.com/401
warnings.warn("Problem related to Sumo upload: " f"{err}")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants