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(agents-api): hotfix in workflows.py #1149

Merged
merged 1 commit into from
Feb 11, 2025
Merged

Conversation

Ahmad-mtos
Copy link
Contributor

@Ahmad-mtos Ahmad-mtos commented Feb 11, 2025

PR Type

Bug fix


Description

  • Fixed incorrect slicing index in get_workflow_name function.

  • Ensures proper extraction of workflow name from string.


Changes walkthrough 📝

Relevant files
Bug fix
workflows.py
Fix slicing index for workflow name extraction                     

agents-api/agents_api/common/utils/workflows.py

  • Corrected slicing index for extracting workflow name.
  • Ensures accurate parsing of workflow strings.
  • +1/-1     

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.

  • Important

    Fixes off-by-one error in get_workflow_name() in workflows.py for strings starting with "PAR:`".

    • Bug Fix:
      • Corrects off-by-one error in get_workflow_name() in workflows.py.
      • Adjusts string slicing from workflow_str[6:] to workflow_str[5:] for strings starting with "PAR:`".

    This description was created by Ellipsis for 61d70e8. It will automatically update as commits are pushed.

    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Input Validation

    The function assumes the input string will always contain a backtick after the prefix. Consider adding validation to handle cases where the input string format is invalid.

    workflow_str = workflow_str[5:].split("`")[0]

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Handle missing delimiter edge case

    The current implementation might fail if the input string contains no backtick
    after the prefix. Add a validation check to handle this edge case and prevent
    IndexError.

    agents-api/agents_api/common/utils/workflows.py [6-8]

     if workflow_str.startswith("PAR:`"):
         # Extract between PAR:` and first ` after "workflow"
    -    workflow_str = workflow_str[5:].split("`")[0]
    +    parts = workflow_str[5:].split("`")
    +    workflow_str = parts[0] if parts else workflow_str[5:]
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    __

    Why: The suggestion addresses a potential runtime error (IndexError) that could occur if the input string lacks a closing backtick. This is a significant defensive programming improvement that prevents application crashes.

    Medium

    Copy link
    Contributor

    @ellipsis-dev ellipsis-dev bot left a comment

    Choose a reason for hiding this comment

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

    👍 Looks good to me! Reviewed everything up to 61d70e8 in 21 seconds

    More details
    • Looked at 13 lines of code in 1 files
    • Skipped 0 files when reviewing.
    • Skipped posting 2 drafted comments based on config settings.
    1. agents-api/agents_api/common/utils/workflows.py:8
    • Draft comment:
      Corrects off-by-one error: Prefix "PAR:`" is 5 characters long, not 6.
    • Reason this comment was not posted:
      Comment did not seem useful. Confidence is useful = 0% <= threshold 50%
      This comment is purely informative, pointing out a correction made in the code regarding an off-by-one error. It doesn't suggest any changes or ask for confirmation on the intention. According to the rules, purely informative comments should be removed.
    2. agents-api/agents_api/common/utils/workflows.py:8
    • Draft comment:
      Fix off-by-one error: 'PAR:`' prefix is 5 chars, so slice should start at index 5.
    • Reason this comment was not posted:
      Marked as duplicate.

    Workflow ID: wflow_YM7l0lf9J45NbO8b


    You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

    @Ahmad-mtos Ahmad-mtos merged commit bc80033 into main Feb 11, 2025
    10 of 12 checks passed
    @Ahmad-mtos Ahmad-mtos deleted the x/paralellism-inputs-hotfix branch February 11, 2025 12:25
    Copy link
    Contributor

    CI Feedback 🧐

    A test triggered by this PR failed. Here is an AI-generated analysis of the failure:

    Action: Typecheck

    Failed stage: Typecheck [❌]

    Failed test name: agents_api.autogen.openapi_model

    Failure summary:

    The pytype check failed due to invalid type annotations in the file
    agents_api/autogen/openapi_model.py:

  • Invalid base class error in the ListResponse class definition
  • Invalid type annotation for the items field using list[DataT]
  • The error occurs because the generic type parameter DataT is not properly defined or recognized by
    pytype

  • Relevant error logs:
    1:  ##[group]Operating System
    2:  Ubuntu
    ...
    
    1355:  [19/300] check agents_api.queries.utils
    1356:  [20/300] check agents_api.common.utils.db_exceptions
    1357:  [21/300] check agents_api.queries.docs.utils
    1358:  [22/300] check agents_api.common.protocol.developers
    1359:  [23/300] check agents_api.dependencies.exceptions
    1360:  [24/300] check agents_api.worker.codec
    1361:  [25/300] check agents_api.common.nlp
    1362:  [26/300] check agents_api.autogen.openapi_model
    1363:  FAILED: /home/runner/work/julep/julep/agents-api/.pytype/pyi/agents_api/autogen/openapi_model.pyi 
    1364:  /home/runner/work/julep/julep/agents-api/.venv/bin/python -m pytype.main --disable pyi-error --imports_info /home/runner/work/julep/julep/agents-api/.pytype/imports/agents_api.autogen.openapi_model.imports --module-name agents_api.autogen.openapi_model --platform linux -V 3.12 -o /home/runner/work/julep/julep/agents-api/.pytype/pyi/agents_api/autogen/openapi_model.pyi --analyze-annotated --nofail --none-is-not-bool --quick --strict-none-binding /home/runner/work/julep/julep/agents-api/agents_api/autogen/openapi_model.py
    1365:  /home/runner/work/julep/julep/agents-api/agents_api/autogen/openapi_model.py:37:1: error: in <module>: Invalid base class: (<instance of Callable>,) [base-class-error]
    1366:  class ListResponse[DataT: BaseModel](BaseModel):
    1367:  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1368:  items: list[DataT]
    1369:  ~~~~~~~~~~~~~~~~~~~~~~
    1370:  /home/runner/work/julep/julep/agents-api/agents_api/autogen/openapi_model.py:38:12: error: in ListResponse: Invalid type annotation '<instance of Callable>'  [invalid-annotation]
    1371:  Not a type
    1372:  items: list[DataT]
    1373:  ~~~~~~~~~~~
    1374:  For more details, see https://google.github.io/pytype/errors.html
    ...
    
    1438:  [90/300] check tests.sample_tasks.__init__
    1439:  [91/300] check agents_api.common.exceptions.users
    1440:  [92/300] check agents_api.activities.__init__
    1441:  [93/300] check agents_api.common.exceptions.sessions
    1442:  [94/300] check agents_api.rec_sum.trim
    1443:  [95/300] check agents_api.rec_sum.__init__
    1444:  [96/300] check agents_api.rec_sum.summarize
    1445:  [97/300] check tests.test_nlp_utilities
    1446:  ninja: build stopped: cannot make progress due to previous errors.
    1447:  Computing dependencies
    1448:  Generated API key since not set in the environment: 83744865341250205823610360755423
    1449:  Sentry DSN not found. Sentry will not be enabled.
    1450:  Analyzing 290 sources with 0 local dependencies
    1451:  Leaving directory '.pytype'
    1452:  ##[error]Process completed with exit code 1.
    

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant