This repository was archived by the owner on Mar 6, 2026. It is now read-only.
Commit 97bfea9
authored
fix: removes
When performing a IMDS request, the code incorrectly adds a content-type
header to the request:
`content-type: application/json` to AWS metadata (IMDS) GET requests.`
Some services at AWS (such as AWS SageMaker Jupyter notebook) have a
stricter than normal metadata server (IMDS, both v1 and v2) when it
comes to handling incoming http requests.
This PR removes the default content-header and replaces it with `None`.
NOTE: initializing headers to `None` (instead of an empty `dict`) when
no session token is present matches the existing behavior in
`_get_metadata_role_name` and allows the transport adapter to handle
default headers cleanly.
This PR updates existing unit tests (`tests/test_aws.py`) to match the
new behavior.
NOTE: closing PR #1489 due to inactivity as we make the push to migrate
this library to the `google-cloud-python` monorepo
For more information about the genesis of this, see the following issue:
https://issuetracker.google.com/issues/328089077content-header from AWS IMDS get request (#1934)1 parent 35670fc commit 97bfea9Copy full SHA for 97bfea9
2 files changed
+5-10Lines changed: 5 additions & 10 deletions
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- google/auth
- tests
Expand file treeCollapse file tree
Open diff view settings
Collapse file
+3-2Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
530 | 530 | |
531 | 531 | |
532 | 532 | |
533 | | - |
534 | 533 | |
535 | | - |
| 534 | + |
| 535 | + |
| 536 | + |
536 | 537 | |
537 | 538 | |
538 | 539 | |
|
Collapse file
+2-8Lines changed: 2 additions & 8 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1306 | 1306 | |
1307 | 1307 | |
1308 | 1308 | |
1309 | | - |
| 1309 | + |
1310 | 1310 | |
1311 | 1311 | |
1312 | 1312 | |
| ||
1329 | 1329 | |
1330 | 1330 | |
1331 | 1331 | |
1332 | | - |
| 1332 | + |
1333 | 1333 | |
1334 | 1334 | |
1335 | 1335 | |
| ||
1394 | 1394 | |
1395 | 1395 | |
1396 | 1396 | |
1397 | | - |
1398 | 1397 | |
1399 | 1398 | |
1400 | 1399 | |
| ||
1431 | 1430 | |
1432 | 1431 | |
1433 | 1432 | |
1434 | | - |
1435 | 1433 | |
1436 | 1434 | |
1437 | 1435 | |
| ||
1488 | 1486 | |
1489 | 1487 | |
1490 | 1488 | |
1491 | | - |
1492 | 1489 | |
1493 | 1490 | |
1494 | 1491 | |
| ||
1545 | 1542 | |
1546 | 1543 | |
1547 | 1544 | |
1548 | | - |
1549 | 1545 | |
1550 | 1546 | |
1551 | 1547 | |
| ||
1596 | 1592 | |
1597 | 1593 | |
1598 | 1594 | |
1599 | | - |
1600 | 1595 | |
1601 | 1596 | |
1602 | 1597 | |
| ||
1684 | 1679 | |
1685 | 1680 | |
1686 | 1681 | |
1687 | | - |
1688 | 1682 | |
1689 | 1683 | |
1690 | 1684 | |
|
0 commit comments