Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sentry error #293

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from
Open

Fix sentry error #293

wants to merge 2 commits into from

Conversation

pablotransifex
Copy link

Problem and/or solution

fixes this sentry error: https://sentry.io/organizations/transifex/issues/2918954663/?referrer=slack

How to test

Reviewer checklist

Code:

  • Change is covered by unit-tests
  • Code is well documented, well styled and is following best practices
  • Performance issues have been taken under consideration
  • Errors and other edge-cases are handled properly

PR:

  • Problem and/or solution are well-explained
  • Commits have been squashed so that each one has a clear purpose
  • Commits have a proper commit message according to TEM

@@ -382,7 +382,8 @@ def compile(self, template, stringset, is_source=True, language_info=None,

# This is needed in case the first tag is skipped to retain
# the file's formating
first_tag_position = parsed.text_position + len(parsed.text)
parsed_text_length = len(parsed.text) if parsed.text else 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually both parsed.text and text_position are None. Look:

In [41]: parsed.__dict__
Out[41]: 
{'source': '<resources/>\n',
 'start': 0,
 '_position': 0,
 '_tag': 'resources',
 '_attrib': {},
 '_attrib_string': '',
 '_attributes': [],
 '_text_position': None,
 '_text': None,
 '_content_end': openformats.utils.xml.NewDumbXml.NOT_CACHED,
 '_tail_position': 12,
 '_tail': openformats.utils.xml.NewDumbXml.NOT_CACHED}

In [40]: first_tag_position = parsed.text_position + 0
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In [40], line 1
----> 1 first_tag_position = parsed.text_position + 0

TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

Copy link
Contributor

Choose a reason for hiding this comment

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

As you see from the above dumped parsed object the template is empty! The resource https://www.transifex.com/careem-1/ridehail-android/translate/#ur/features_ridehail_ui doesn't contain any strings. So I believe we are safe to put it like:

if parsed.text and parsed.text_position:
  first_tag_position = parsed.text_position + len(parsed.text)
  self.transcriber.copy_until(first_tag_position)

The rest of the compile() method code will run without errors...

Copy link
Author

Choose a reason for hiding this comment

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

Done

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.

None yet

2 participants