Skip to content

Properly handle permissions#31

Merged
BioWilko merged 30 commits intomainfrom
perms-test-dev
Dec 8, 2025
Merged

Properly handle permissions#31
BioWilko merged 30 commits intomainfrom
perms-test-dev

Conversation

@BioWilko
Copy link
Copy Markdown
Member

@BioWilko BioWilko commented Dec 3, 2025

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements RabbitMQ permission handling by introducing a "check before create" pattern for exchanges and queues. When a client lacks permissions to create resources, the code first attempts to verify the resource exists (using passive=True), and only attempts creation if it doesn't exist (404 error). This allows limited-permission clients to work with existing resources while still enabling resource creation when permitted.

Key Changes:

  • Added passive checking pattern for exchange and queue declarations in producer and consumer
  • Changed queue_suffix parameter default from False to "" (empty string) for better type consistency
  • Added comprehensive permission tests to validate behavior with restricted users
  • Updated RabbitMQ configuration to support permission-based testing

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
varys/producer.py Implements passive checking for exchanges/queues; adds exception handling for permission-based resource management
varys/consumer.py Implements passive checking for exchanges/queues; adds exception handling for permission-based resource management
varys/controller.py Changes queue_suffix default from False to "" for type consistency
tests/test_varys.py Adds comprehensive test suite for permission scenarios including extant/non-extant resources
.rabbitmq/definitions.json Defines RabbitMQ users and permission patterns for testing
.rabbitmq/rabbitmq.conf Configures RabbitMQ to load permission definitions
.github/workflows/pytest.yml Updates RabbitMQ Docker version and increases test timeout to accommodate permission tests
setup.cfg Version bump to 1.2.0
.gitignore Adds varys_client.egg-info directory

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread varys/producer.py Outdated
Comment thread varys/consumer.py Outdated
Comment thread tests/test_varys.py Outdated
Comment thread tests/test_varys.py Outdated
Comment thread varys/consumer.py Outdated
Comment thread varys/consumer.py Outdated
Comment thread varys/producer.py Outdated
Comment thread tests/test_varys.py Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_varys.py
Comment thread tests/test_varys.py
Comment thread tests/test_varys.py Outdated
Comment thread .rabbitmq/definitions.json
Comment thread .rabbitmq/definitions.json
Comment thread varys/consumer.py Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (2)

varys/producer.py:136

  • After catching a 404 error for the queue, the code re-declares the exchange with passive=True. This is unnecessary since the exchange already exists (it was successfully declared or verified earlier in lines 98-117). The exchange declaration here should either be removed, or if it's needed for safety, should not use passive=True since we're in a creation flow.
                    self._channel.queue_declare(queue=self._queue, durable=True)

                self._channel.queue_bind(
                    queue=self._queue,
                    exchange=self._exchange,
                    routing_key=self._routing_key,

varys/consumer.py:112

  • After catching a 404 error for the queue, the code re-declares the exchange with passive=True. This is unnecessary since the exchange already exists (it was successfully declared or verified earlier in lines 75-94). The exchange declaration here should either be removed, or if it's needed for safety, should not use passive=True since we're in a creation flow.
                    self._channel.queue_declare(queue=self._queue, durable=True)

                self._channel.queue_bind(
                    queue=self._queue,
                    exchange=self._exchange,
                    routing_key=self._routing_key,

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_varys.py
Comment thread tests/test_varys.py
Comment thread tests/test_varys.py
Comment thread tests/test_varys.py
@BioWilko BioWilko merged commit 979b5ef into main Dec 8, 2025
10 checks passed
@BioWilko BioWilko deleted the perms-test-dev branch December 8, 2025 09:44
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

Successfully merging this pull request may close these issues.

2 participants