GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [fix][fn] Only load crypto_key_reader for python function when cryptoKeyReaderConfig is provided by jiangpengcheng · Pull Request #24783 · apache/pulsar

Conversation

@jiangpengcheng

@jiangpengcheng jiangpengcheng commented Sep 25, 2025

Copy link
Copy Markdown
Contributor

Fixes #24782

Motivation

The python function will try to load crypto_config from crypto_spec.cryptoKeyReaderConfig even it's empty or None, which will show an un-expected error log Failed to load the crypto key reader from spe

Modifications

check the crypto_spec.cryptoKeyReaderConfig before load it

Verifying this change

  • Make sure that the change passes the CI checks.

  • This change is a trivial rework / code cleanup without any test coverage.

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: jiangpengcheng#48

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
jiangpengcheng added 2 commits September 25, 2025 16:10
@jiangpengcheng
[fix][fn] Only load crypto_key_reader when cryptoKeyReaderConfig is p…
6c8c74b
…rovided
@jiangpengcheng
add test
fb12bd3
@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Sep 25, 2025
@Zhianii Zhianii mentioned this pull request Sep 9, 2026
[fix][fn] Honour consumerCryptoFailureAction in the Python function runtime #26490
Merged
10 tasks
merlimat added 2 commits October 22, 2026 11:25
@merlimat
Merge remote-tracking branch 'apache/master' into mmerli/pr-24783-cry…
032ba0c
…pto-reader

# Conflicts:
#	pulsar-functions/instance/src/main/python/python_instance.py
@merlimat
[fix][fn] Skip the crypto key reader only for an empty cryptoSpec
d774784
Replace the public/private key path check with an early return for a spec
that has neither a reader class nor a config, so a partial default-reader
config still logs an error instead of silently disabling encryption, and
cover get_crypto_reader() with unit tests.
merlimat
merlimat approved these changes Oct 22, 2026
View reviewed changes
@merlimat

merlimat commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Hi @jiangpengcheng, thanks for this fix. It's still needed on master: an unset cryptoSpec comes back as an empty default message, not None, so every Python function without crypto calls json.loads("") once for its producer and once per input topic, and logs Failed to load the crypto key reader from spec.

I pushed two commits to your branch to get it ready to merge:

  1. Merged master (032ba0c). The only conflict was the blank line before get_crypto_reader, where master has since added new methods. I kept master's side of the file, so this merge drops your original get_crypto_reader change. The next commit replaces it.
  2. Narrowed the check (d774784). Instead of building the default reader only when both public_key_path and private_key_path are present, get_crypto_reader now returns None early only when the spec has neither cryptoKeyReaderClassName nor cryptoKeyReaderConfig. Otherwise, a partial config (for example, only a public key) would quietly turn encryption off instead of logging an error. A custom reader class with no config is now created with no arguments instead of failing to parse "". I also added unit tests in test_python_instance.py (TestGetCryptoReader) for an unset spec on the producer and on an input, for a partial config, and for a custom class with no config. Your integration-test check in PulsarFunctionsTest is unchanged.

Let me know if that works for you.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@merlimat merlimat added this to the 5.1.0 milestone Oct 22, 2026
@merlimat
merlimat merged commit cef020c into apache:master Oct 22, 2026
45 checks passed

Uh oh!

There was an error while loading. Please reload this page.

lhotari pushed a commit that referenced this pull request Oct 22, 2026
@jiangpengcheng @merlimat @lhotari
[fix][fn] Only load crypto_key_reader for python function when crypto…
2854520
…KeyReaderConfig is provided (#24783)

Co-authored-by: Matteo Merli <[email protected]>
(cherry picked from commit cef020c)
This was referenced Nov 21, 2026
[improve][ci] Run CI for the 4.2.6 backports to branch-4.2 (do not merge) #27680
Closed
[improve][ci] Run CI for the 4.2.6 backports to branch-4.2 (do not merge) #27681
Closed
[improve][ci] Run CI for the 4.2.6 backports to branch-4.2 (do not merge) #27684
Closed
@lhotari lhotari added cherry-picked/branch-4.2 release/4.2.6 cherry-picked/branch-4.0 release/4.0.15 labels Nov 21, 2026
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request Nov 26, 2026
@jiangpengcheng @merlimat @lhotari
[fix][fn] Only load crypto_key_reader for python function when crypto…
149d5f1
…KeyReaderConfig is provided (apache#24783)

Co-authored-by: Matteo Merli <[email protected]>
(cherry picked from commit cef020c)
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request Nov 26, 2026
@jiangpengcheng @merlimat @lhotari
[fix][fn] Only load crypto_key_reader for python function when crypto…
3564cf9
…KeyReaderConfig is provided (apache#24783)

Co-authored-by: Matteo Merli <[email protected]>
(cherry picked from commit cef020c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@merlimat merlimat merlimat approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cherry-picked/branch-4.0 cherry-picked/branch-4.2 doc-not-needed Your PR changes do not impact docs release/4.0.15 release/4.2.6

Projects

None yet

Milestone

5.1.0

Development

Successfully merging this pull request may close these issues.

[Bug] Python function report error Failed to load the crypto key reader from spec

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@jiangpengcheng @merlimat @lhotari
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.