Skip to content

Conversation

@johnnyshut
Copy link
Contributor

@johnnyshut johnnyshut commented Jan 7, 2026

Описание

  • Добавлен блок catch для неожиданных исключений в ExtendXStream, регистрирующий сообщение об ошибке.
  • Обновлен RoleConverter для обработки результата ExtendXStream.read, гарантирующий присвоение значения RoleData.EMPTY, если результат чтения не является допустимым экземпляром RoleData.

Связанные задачи

Closes #563

Чеклист

Общие

  • Ветка PR обновлена из develop
  • Отладочные, закомментированные и прочие, не имеющие смысла участки кода удалены
  • Изменения покрыты тестами
  • Обязательные действия перед коммитом выполнены (запускал команду gradlew precommit)

Summary by CodeRabbit

  • Bug Fixes

    • Downgraded noisy XML parsing errors to warnings and added handling for unexpected failures to avoid crashes.
    • Improved role data conversion to safely handle unexpected or malformed input, preventing type-related failures and ensuring consistent reader context population.
  • Documentation

    • Added and updated inline documentation describing role conversion behavior and path-resolution utilities.

✏️ Tip: You can customize this high-level summary in your review settings.

- Добавлен блок catch для неожиданных исключений в ExtendXStream, регистрирующий сообщение об ошибке.

- Обновлен RoleConverter для обработки результата ExtendXStream.read, гарантирующий присвоение значения RoleData.EMPTY, если результат чтения не является допустимым экземпляром RoleData.
@coderabbitai
Copy link

coderabbitai bot commented Jan 7, 2026

📝 Walkthrough

Walkthrough

Modify XML deserialization error handling in ExtendXStream and make RoleConverter implementations tolerate non-RoleData results by using runtime type checks, storing fallback RoleData.EMPTY into the reader context, and adding canConvert and dataPath helpers.

Changes

Cohort / File(s) Summary
ExtendXStream exception handling
src/main/java/.../bsl/reader/common/xstream/ExtendXStream.java
Lowered log level from error to warn for ConversionException and StreamException, simplified the StreamException message, and added a generic catch (Exception) that logs an "unexpected error (skipped)" with the exception.
Designer RoleConverter
src/main/java/.../bsl/reader/designer/converter/RoleConverter.java
Replace direct cast from ExtendXStream.read with a typed readResult; if not a RoleData use RoleData.EMPTY. On exceptions also fall back to RoleData.EMPTY. Store result in reader context (DATA_FIELD) before returning; add canConvert and dataPath helper with Javadoc.
EDT RoleConverter
src/main/java/.../bsl/reader/edt/converter/RoleConverter.java
Mirror of designer converter: safe-read into readResult, fallback to RoleData.EMPTY, set reader context DATA_FIELD, add Javadoc and dataPath helper.

Sequence Diagram(s)

sequenceDiagram
  participant RoleConv as RoleConverter
  participant XStream as ExtendXStream
  participant Conv as RoleDataConverter
  participant Context as ReaderContext
  participant Logger as Logger

  RoleConv->>XStream: read(Rights.xml)
  XStream->>Conv: fromXML(...)
  alt successful parse returns RoleData
    Conv-->>XStream: RoleData
    XStream-->>RoleConv: RoleData
    RoleConv->>Context: setValue(DATA_FIELD, RoleData)
  else parse throws Conversion/Stream/other Exception
    Conv--x XStream: throws Exception
    XStream->>Logger: warn(...) / unexpected error warn
    XStream-->>RoleConv: null or skipped
    RoleConv->>Context: setValue(DATA_FIELD, RoleData.EMPTY)
  end
  RoleConv-->>RoleConv: return reader context
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped through XML, nose twitching bright,
When parsing trips, I nudge it light.
A gentle warn, no crash in sight,
I tuck an empty role for night,
And hop along — all snug and right. 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is in Russian and indicates improvement of error handling in RoleConverter and ExtendXStream, which directly corresponds to the main changes in the pull request.
Linked Issues check ✅ Passed The PR addresses all coding objectives from issue #563: adding catch blocks in ExtendXStream to handle unexpected exceptions and log errors, and modifying RoleConverter to safely handle non-RoleData results by using RoleData.EMPTY instead of failing.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing error handling in RoleConverter and ExtendXStream as required by issue #563; no out-of-scope modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

…ием уровня WARN

- Изменено логирование ошибок с ERROR на WARN для некорректного чтения файлов и непредвиденных ошибок.
…ния понимания кода

- Добавлены Javadoc комментарии для методов и класса, описывающие их функциональность и параметры.
- Обновлены пути к файлам прав доступа.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d766b5c and b09c113.

📒 Files selected for processing (3)
  • src/main/java/com/github/_1c_syntax/bsl/reader/common/xstream/ExtendXStream.java
  • src/main/java/com/github/_1c_syntax/bsl/reader/designer/converter/RoleConverter.java
  • src/main/java/com/github/_1c_syntax/bsl/reader/edt/converter/RoleConverter.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/java/com/github/_1c_syntax/bsl/reader/common/xstream/ExtendXStream.java
  • src/main/java/com/github/_1c_syntax/bsl/reader/edt/converter/RoleConverter.java
🧰 Additional context used
🧬 Code graph analysis (1)
src/main/java/com/github/_1c_syntax/bsl/reader/designer/converter/RoleConverter.java (3)
src/main/java/com/github/_1c_syntax/bsl/reader/designer/converter/TemplateConverter.java (1)
  • DesignerConverter (40-98)
src/main/java/com/github/_1c_syntax/bsl/reader/designer/converter/XDTOPackageConverter.java (1)
  • DesignerConverter (34-63)
src/main/java/com/github/_1c_syntax/bsl/reader/designer/converter/ExchangePlanConverter.java (1)
  • DesignerConverter (33-54)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: build (21, windows-latest)
  • GitHub Check: build (17, windows-latest)
  • GitHub Check: build (25, ubuntu-latest)
  • GitHub Check: build (17, macOS-latest)
  • GitHub Check: build (21, ubuntu-latest)
  • GitHub Check: build (17, ubuntu-latest)
  • GitHub Check: build (25, windows-latest)
  • GitHub Check: build (25, macOS-latest)
🔇 Additional comments (2)
src/main/java/com/github/_1c_syntax/bsl/reader/designer/converter/RoleConverter.java (2)

34-48: LGTM! Well-documented converter.

The added JavaDoc clearly describes the converter's purpose and the unmarshal method's behavior, including the handling of Rights.xml files. The documentation style is consistent with the codebase.


70-90: LGTM! Clear helper methods with proper documentation.

The canConvert method correctly identifies Role types, and the dataPath helper properly constructs the path to Rights.xml. The JavaDoc clearly documents the behavior and parameters.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/main/java/com/github/_1c_syntax/bsl/reader/edt/converter/RoleConverter.java (1)

33-35: Documentation improvements enhance code maintainability.

The added Javadoc comments clearly document the purpose and behavior of the converter class and its methods, making the code easier to understand and maintain.

Also applies to: 41-47, 69-74, 80-85

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b09c113 and 96a415f.

📒 Files selected for processing (3)
  • src/main/java/com/github/_1c_syntax/bsl/reader/common/xstream/ExtendXStream.java
  • src/main/java/com/github/_1c_syntax/bsl/reader/designer/converter/RoleConverter.java
  • src/main/java/com/github/_1c_syntax/bsl/reader/edt/converter/RoleConverter.java
🧰 Additional context used
🧬 Code graph analysis (2)
src/main/java/com/github/_1c_syntax/bsl/reader/designer/converter/RoleConverter.java (3)
src/main/java/com/github/_1c_syntax/bsl/reader/designer/converter/TemplateConverter.java (1)
  • DesignerConverter (40-98)
src/main/java/com/github/_1c_syntax/bsl/reader/designer/converter/XDTOPackageConverter.java (1)
  • DesignerConverter (34-63)
src/main/java/com/github/_1c_syntax/bsl/reader/designer/converter/ExchangePlanConverter.java (1)
  • DesignerConverter (33-54)
src/main/java/com/github/_1c_syntax/bsl/reader/edt/converter/RoleConverter.java (1)
src/main/java/com/github/_1c_syntax/bsl/reader/edt/converter/XDTOPackageConverter.java (1)
  • EDTConverter (33-61)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: build (17, macOS-latest)
  • GitHub Check: build (25, windows-latest)
  • GitHub Check: build (21, macOS-latest)
  • GitHub Check: build (25, ubuntu-latest)
  • GitHub Check: build (21, windows-latest)
  • GitHub Check: build (21, ubuntu-latest)
  • GitHub Check: build (25, macOS-latest)
  • GitHub Check: build (17, windows-latest)
  • GitHub Check: build (17, ubuntu-latest)
🔇 Additional comments (6)
src/main/java/com/github/_1c_syntax/bsl/reader/common/xstream/ExtendXStream.java (2)

125-130: Appropriate log level changes for corrupted file scenarios.

Changing from error to warn for ConversionException and StreamException is correct since corrupted files are an expected scenario that should be logged but not treated as critical errors.

However, note that line 130 simplified the message format. Both catch blocks log the exception object (third parameter) but the messages are slightly inconsistent in their phrasing.


131-133: Verify that catch-all exception handling won't mask development errors.

The broad Exception catch provides resilience against unexpected errors during XML deserialization, which aligns with the PR's goal of gracefully handling corrupted files. However, this could potentially mask genuine programming errors (NPE, IllegalArgumentException, etc.) during development.

Consider whether this catch-all should:

  • Only apply in production mode, or
  • Be more selective about which exception types are treated as "corrupted file" vs "programming error"

The full exception is logged, which helps debugging, but developers might not notice warnings as readily as errors during testing.

src/main/java/com/github/_1c_syntax/bsl/reader/edt/converter/RoleConverter.java (3)

53-59: Type-safe read with appropriate fallback.

The instanceof check with pattern matching prevents ClassCastException and handles cases where the XML file is corrupted or returns an unexpected type. The fallback to RoleData.EMPTY allows processing to continue gracefully, which directly addresses issue #563.


65-66: Essential fix: Storing data in reader context.

The addition of readerContext.setValue(DATA_FIELD, data) before returning is crucial. This ensures the parsed role data is properly stored in the reader context and accessible to downstream processing. Based on the AI summary indicating this "replaces the previous flow that returned without setting the context value," this appears to fix a bug where role data was being read but not stored.

This pattern is consistent with similar converters like XDTOPackageConverter.


60-63: LGTM: Exception handling for corrupted files.

The catch block appropriately handles any exceptions during file reading by falling back to RoleData.EMPTY, allowing the processing pipeline to continue despite corrupted role data files. This aligns with the PR objective of graceful degradation when encountering invalid XML.

src/main/java/com/github/_1c_syntax/bsl/reader/designer/converter/RoleConverter.java (1)

34-36: Consistent implementation mirrors EDT converter.

The changes to the designer format RoleConverter appropriately mirror the fixes applied to the EDT version:

  • Added comprehensive Javadoc documentation
  • Type-safe instanceof check prevents ClassCastException
  • Fallback to RoleData.EMPTY for corrupted files
  • Proper storage of data in reader context via setValue

The only format-specific difference is the file path (Rights.xml for designer format vs Rights.rights for EDT format), which is correct.

Also applies to: 42-48, 54-60, 66-67, 70-75, 81-87

@theshadowco theshadowco merged commit 54237f6 into 1c-syntax:develop Jan 8, 2026
12 checks passed
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.

ConversionException:

2 participants