Skip to content

Bug fixes and improvments#273

Merged
ehsan-fj merged 18 commits into
developfrom
bug-fixes-and-improvments
May 25, 2026
Merged

Bug fixes and improvments#273
ehsan-fj merged 18 commits into
developfrom
bug-fixes-and-improvments

Conversation

@ehsan-fj

@ehsan-fj ehsan-fj commented May 21, 2026

Copy link
Copy Markdown
Member

This pull request introduces several improvements and bug fixes to the PyEPP package, focusing on better handling of falsy values in command preparation, enhanced DNSSEC support in domain creation, improved socket communication, and expanded test coverage. The changes also include updates to development dependencies and minor template corrections.

Key highlights:

  • The command preparation logic now correctly preserves falsy values (like 0 and False), ensuring accurate XML rendering and data transmission.
  • DNSSEC support for domain creation is improved, allowing both single and multiple DS records.
  • Socket communication is made more robust, handling partial reads and empty responses gracefully.
  • Test coverage is significantly expanded, including new tests for EPP communication, DNSSEC handling, and utility functions.
  • Minor template and documentation corrections are included.

Command Preparation and Data Handling

  • Updated BaseCommand._prepare_command, __escape_list, and __escape_dict to preserve falsy values (0, False) instead of filtering them out, ensuring these values are correctly rendered in XML commands. [1] [2] [3]
  • Added tests to verify that falsy values are preserved in command preparation and escaping logic (test_prepare_command_falsy_values, test_escape_list, test_escape_dict). [1] [2]

DNSSEC and Domain Creation Enhancements

  • Improved DNSSEC support in the domain creation template to handle both single and multiple DS records, and added tests to verify correct XML rendering for both cases. [1] [2]
  • Added tests to ensure explicit password usage and correct handling of missing DNSSEC data in domain info responses.

EPP Communicator and Socket Robustness

  • Refactored socket read (_read) and write (_write) methods to handle empty reads, partial data, and use sendall for reliability. The _read method now returns None on empty or broken responses, improving error handling. [1] [2] [3]
  • Simplified get_format_32 to always return ">I", removing unnecessary logic.
  • Added comprehensive unit tests for EppCommunicator, covering error scenarios, connection logic, and dry-run behavior.

Template and Dependency Fixes

  • Fixed a typo in the domain transfer template (<domain:pw> closing tag).
  • Updated development dependencies in requirements.dev.txt to newer versions.

Miscellaneous Improvements

  • Added unit tests for the helper XML pretty-printing function.
  • Bumped package version to 0.2.0.This pull request introduces several improvements and bug fixes to the PyEPP package, focusing on better handling of falsy values in command preparation, improved DNSSEC record rendering, more robust socket communication, and general code quality enhancements. The changes also include new and updated tests to ensure correctness and reliability.

Core logic and bug fixes:

  • Updated the _prepare_command, __escape_list, and __escape_dict methods in BaseCommand to preserve falsy values like 0 and False, instead of filtering them out, ensuring these values are correctly rendered in XML commands. [1] [2] [3]
  • Fixed the DNSSEC (dns_sec) rendering in command_templates.py so that both single and multiple DS records are rendered correctly in the generated XML.
  • Corrected a typo in the domain transfer template, changing </domains:pw> to </domain:pw>.

Socket communication improvements:

  • Simplified the get_format_32 function to always return the correct struct format, and improved the _read and _write methods in EppCommunicator to use sendall for reliability and to handle partial reads and empty chunks more gracefully. [1] [2] [3] [4]

Testing and code quality:

  • Added and updated tests in test_base_command.py and test_domain.py to verify preservation of falsy values and correct DNSSEC rendering, and improved socket communication tests in test_pyepp.py. [1] [2] [3] [4]
  • Updated development dependencies in requirements.dev.txt for better code quality and security.
  • Bumped package version to 0.2.0 in __init__.py.

ehsan-fj added 5 commits May 21, 2026 20:27
…egitimate falsy values (like `0` or `False`) because they check `elif value:` instead of `elif value is not None:`.

Fix:** Update the conditionals to explicitly check for `None`.
… use sendall instead of send to make sure all the data is sent.

The `get_format_32()` function is unnecessary as `struct.calcsize(">I")` is guaranteed to be 4 bytes in Python.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 focuses on improving EPP protocol robustness and fixing XML template issues, along with a version bump to reflect the changes.

Changes:

  • Simplifies the 32-bit length-field packing format and improves socket send/receive behavior.
  • Extends the domain create template to support multiple DNSSEC DS records and fixes an invalid XML closing tag.
  • Adjusts escaping to preserve falsy-but-valid values in nested structures; bumps package version and updates .gitignore.

Reviewed changes

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

Show a summary per file
File Description
pyepp/epp.py Simplifies length packing, improves _read() buffering logic, switches _write() to sendall().
pyepp/command_templates.py Adds support for list/single DNSSEC DS records; fixes domain:pw closing tag typo.
pyepp/base_command.py Preserves non-None falsy values during nested escaping.
pyepp/init.py Bumps package version to 0.2.0 (used by dynamic versioning).
.gitignore Adds ignores for GEMINI/CLAUDE markdown files.
Comments suppressed due to low confidence (1)

pyepp/base_command.py:91

  • The change from elif value: to elif value is not None: is meant to preserve falsy but valid values (e.g., 0, False) in nested lists/dicts. Current unit tests cover escaping of strings but do not assert the new behavior for falsy values, so regressions would be easy to miss. Add test cases for 0/False in both __escape_list and __escape_dict.
                result[key] = self.__escape_dict(value)
            elif isinstance(value, str):
                result[key] = escape(value)
            elif value is not None:
                result[key] = value

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

Comment thread pyepp/epp.py
Comment thread pyepp/epp.py
Comment thread pyepp/base_command.py
Comment thread pyepp/command_templates.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 10 changed files in this pull request and generated 3 comments.

Comment thread pyepp/epp.py
Comment thread pyepp/base_command.py Outdated
Comment thread tests/test_pyepp.py
@ehsan-fj ehsan-fj marked this pull request as ready for review May 21, 2026 09:39
@ehsan-fj ehsan-fj requested a review from levius0 May 21, 2026 09:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 12 out of 14 changed files in this pull request and generated 4 comments.

Comment thread pyepp/epp.py
Comment thread tests/test_pyepp.py
Comment thread tests/test_poll.py Outdated
Comment thread tests/test_poll.py Outdated
ehsan-fj and others added 4 commits May 22, 2026 10:50
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@ehsan-fj ehsan-fj merged commit ad09e64 into develop May 25, 2026
5 checks passed
@ehsan-fj ehsan-fj deleted the bug-fixes-and-improvments branch May 25, 2026 08:37
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