Skip to content

Conversation

ChuckJonas
Copy link
Contributor

Description

Seems like theres a bad reference to a non-existent type.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

No, I have no idea how to reproduce this as it was in the middle of a complicated bug and it crashed my application with:

module 'json' has no attribute 'DecodeError'
module 'json' has no attribute 'DecodeError'. Did you mean: 'JSONDecodeError'

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

Copy link

linux-foundation-easycla bot commented Sep 25, 2025

CLA Signed

  • ✅login: ChuckJonas / name: Charlie Jonas / (fd27c87)

The committers listed above are authorized under a signed CLA.

@ChuckJonas ChuckJonas changed the title Fix exception handling for JSON decoding Fix module 'json' has no attribute 'DecodeError' Sep 25, 2025
@ChuckJonas ChuckJonas changed the title Fix module 'json' has no attribute 'DecodeError' Fix "module 'json' has no attribute 'DecodeError'" in bedrock Sep 25, 2025
@xrmx
Copy link
Contributor

xrmx commented Sep 25, 2025

@ChuckJonas thanks, any chance you can share what's the content raised the decoding error? We may have a bug elsewhere.

@xrmx xrmx added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Sep 25, 2025
@xrmx xrmx moved this to Easy to review / merge / close in @xrmx's Python PR digest Sep 25, 2025
@xrmx xrmx merged commit 17aba81 into open-telemetry:main Sep 25, 2025
632 of 633 checks passed
@github-project-automation github-project-automation bot moved this from Easy to review / merge / close to Done in @xrmx's Python PR digest Sep 25, 2025
@ChuckJonas
Copy link
Contributor Author

unfortunately not really as I was in the middle of a complicated agent eval so there were many parallel requests happening.

The original error seems to have been: json.decoder.JSONDecodeError: Expecting ',' delimiter: line 1 column 12 (char 11).

This would have been a bedrock-runtime -> converse call.

Traceback (most recent call last):
  File "<site-packages>/opentelemetry/instrumentation/botocore/extensions/bedrock_utils.py", line 117, in _process_event
    self._content_block["toolUse"]["input"] = json.loads(self._tool_json_input_buf)
  File "<python-stdlib>/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "<python-stdlib>/json/decoder.py", line 345, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "<python-stdlib>/json/decoder.py", line 361, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 1 column 12 (char 11)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<app>/packages/agent-service/src/ag_ui_publisher.py", line 153, in worker
    await work(publisher)
  File "<app>/packages/agent-service/src/agents/advice/advice_agent.py", line 353, in work
    await run_advice_agent(...)
  File "<site-packages>/weave/trace/op.py", line 1221, in wrapper
    res, _ = await _call_async_func(cast(Op[P, R], wrapper), *args, __should_raise=True, **kwargs)
  File "<site-packages>/weave/trace/op.py", line 633, in _call_async_func
    res = await func(*args, **kwargs)
  File "<app>/packages/agent-service/src/agents/advice/advice_agent.py", line 272, in run_advice_agent
    result = await stream_agent(...)
  File "<app>/packages/agent-service/src/stream_agent.py", line 92, in stream_agent
    async for event in request_stream:
  File "<site-packages>/pydantic_ai/models/__init__.py", line 579, in iterator_with_final_event
    async for event in iterator:
  File "<site-packages>/pydantic_ai/models/bedrock.py", line 650, in _get_event_iterator
    async for chunk in _AsyncIteratorWrapper(self._event_stream):
  File "<site-packages>/pydantic_ai/models/bedrock.py", line 744, in __anext__
    return await anyio.to_thread.run_sync(next, self.sync_iterator)
  File "<site-packages>/anyio/to_thread.py", line 56, in run_sync
    return await get_async_backend().run_sync_in_worker_thread(func, args, abandon_on_cancel=abandon_on_cancel, limiter=limiter)
  File "<site-packages>/anyio/_backends/_asyncio.py", line 2476, in run_sync_in_worker_thread
    return await future
  File "<site-packages>/anyio/_backends/_asyncio.py", line 967, in run
    result = context.run(func, *args)
  File "<site-packages>/opentelemetry/instrumentation/botocore/extensions/bedrock_utils.py", line 74, in __iter__
    self._process_event(event)
  File "<site-packages>/opentelemetry/instrumentation/botocore/extensions/bedrock_utils.py", line 120, in _process_event
    except json.DecodeError:
AttributeError: module 'json' has no attribute 'DecodeError'. Did you mean: 'JSONDecodeError'?

zhirafovod pushed a commit to zhirafovod/opentelemetry-python-contrib that referenced this pull request Sep 26, 2025
* cherry pick changes from previous PR

* move span utils to new file

* remove span state, use otel context for parent/child

* flatten LLMInvocation to use attributes instead of dict keys

* helper function and docstrings

* refactor: store span and context token in LLMInvocation instead of SpanGenerator

* refactor: rename prompts/chat_generations to input_messages/output_messages for clarity

* refactor: simplify TelemetryHandler API by moving invocation data management to LLMInvocation class

* refactor: update relative imports to absolute imports

* Update handler to use a context manager instead of start_llm and stop_llm

* resolve tox -e doc failure

* safeguard against empty request-model

* fix tox typecheck errors for utils

* refactor: move tracer to generator, clean up dead code

* remove unused linting hint

* back off stricter request-model requirements

* reintroduce manual start/stop for langchain callback flow

* Fix typecheck in langchain instrumentation (open-telemetry#3773)

* fix typecheck

* fix ruff and added changelog

* added lambda list

* Update instrumentation-genai/opentelemetry-instrumentation-langchain/CHANGELOG.md

---------

Co-authored-by: Riccardo Magliocchetti <[email protected]>

* botocore: Add support for AWS Secrets Manager semantic convention attribute (open-telemetry#3765)

* botocore: Add support for AWS Secrets Manager semantic convention attribute

AWS Secrets Manager defines semantic convention attribute:

AWS_SECRETSMANAGER_SECRET_ARN: Final = "aws.secretsmanager.secret.arn"

https://github.com/open-telemetry/semantic-conventions/blob/main/docs/registry/attributes/aws.md#amazon-secrets-manager-attributes

Currently, this attribute is not set in the botocore instrumentation library. This PR adds support for them by extracting values from both Request and Response objects.

Tests
Added new unit tests (passing).

Verified with:
tox -e py312-test-instrumentation-botocore
tox -e spellcheck
tox -e lint-instrumentation-botocore
tox -e ruff

Backward Compatibility
This change is backward compatible. It only adds instrumentation for additional AWS resources and does not modify existing behavior in the auto-instrumentation library.

* add ChangeLog.

* Update instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/secretsmanager.py

Co-authored-by: Tammy Baylis <[email protected]>

* Update instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_secretsmanager.py

---------

Co-authored-by: Tammy Baylis <[email protected]>
Co-authored-by: Emídio Neto <[email protected]>
Co-authored-by: Riccardo Magliocchetti <[email protected]>

* clean up context handler, clarify unit tests

* Rename UploadHook -> CompletionHook (open-telemetry#3780)

* Add opentelemetry-util-genai to the package release workflow (open-telemetry#3781)

* Fix package release workflows version.py finding (open-telemetry#3782)

Looking at the files in this repo, the version file is always called version.py (and it should be). Tested the find command locally.

```shell
$ for f in $(git ls-files '*version*.py'); do basename $f; done | sort -u
test_version.py
version.py

$ find util/opentelemetry-util-genai/ -type f -path "**/version.py"
util/opentelemetry-util-genai/src/opentelemetry/util/genai/version.py
```

* Adjust opentelemetry-instrumentation-vertexai dependency on opentelemetry-genai-util (open-telemetry#3785)

This fixes the CI failure on the release PRs for opentelemetry-util-genai

- open-telemetry#3784 (needs cherry pick)
- open-telemetry#3783

* Fix exception handling for JSON decoding (open-telemetry#3787)

* Add rstcheck in pre-commit (open-telemetry#3777)

* Fix a bunch of rstcheck warnings

* Add rstcheck to pre-commit

* Ignore automodule

* Update changelog and contributing

* tox -e ruff -> tox -e precommit

But keep the old name for compat

* remove generator concept

* update token types

* Update opentelemetry-util-genai version to v0.2b0 (open-telemetry#3783)

Co-authored-by: otelbot <[email protected]>
Co-authored-by: Aaron Abbott <[email protected]>

---------

Co-authored-by: wrisa <[email protected]>
Co-authored-by: Riccardo Magliocchetti <[email protected]>
Co-authored-by: Luke (GuangHui) Zhang <[email protected]>
Co-authored-by: Tammy Baylis <[email protected]>
Co-authored-by: Emídio Neto <[email protected]>
Co-authored-by: Aaron Abbott <[email protected]>
Co-authored-by: Charlie Jonas <[email protected]>
Co-authored-by: otelbot[bot] <197425009+otelbot[bot]@users.noreply.github.com>
Co-authored-by: otelbot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants