Skip to content

Conversation

@shaohuzhang1
Copy link
Contributor

fix: Workflow Knowledge Base Execution Record Search Result Exception

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Dec 8, 2025

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Dec 8, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@shaohuzhang1 shaohuzhang1 merged commit 0a5a05f into v2 Dec 8, 2025
3 of 5 checks passed
@shaohuzhang1 shaohuzhang1 deleted the pr@v2@fix_workflow_knowledge branch December 8, 2025 08:32
}
const pre_disable = computed(() => {
const index = tableIndexMap.value[currentId.value] - 1
return index < 0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The provided code has a few issues:

  1. Duplicate Code: The getList function is called with different parameters (query.user_name) in both places where it's triggered by changes to filters (status vs. user_name). It should consistently use one of these based on the filter_type.

  2. Logic Inconsistency: When clearing the page, the condition for resetting the page number is only checked once before calling getList. This makes it inconsistent with how other logic works.

  3. Variable Confusion: There seems to be confusion between the currentId, tableIndexMap, data.value, currentContent, and related variables. These need to be clearly defined and used consistently throughout the component.

Here are some optimizations and corrections:

a. Consistently Use Either status or user_name:

const getList = (clear?: boolean) => {
  if (clear) {
    paginationConfig.current_page = 1;
  }  
  const params = { ...query.value };
  if (!Object.keys(params).length) params[user_filter_key.value] = ''; // Assuming this key exists

  return loadSharedApi({ type: 'knowledge', systemType: apiType.value })
    .getWorkflowActionPage(active_knowledge_id.value, paginationConfig, params, loading)
    .then((ok: any) => {
      paginationConfig.total = ok.data?.total;
      if (clear) {
        data.value = ok.data.records;  
      } else {
        data.value = data.value.concat(ok.data.records);
      }
    });
};

b. Ensure Consistent Use of Variable Names:
Correcting naming inconsistencies helps clarify intentions and avoids mistakes:

type RowState = 'highlight';
let selectedRowHighlightID: string | null = null;

// Check functions can now refer accurately

setRowClass(row): string {
  if (selectedRowHighlightID === row.id) {   
    return 'highlight';
  }

  // Default behavior for un-highlighted rows
}

onNextClick(): void {
  let currentIndex = tableData.findIndex(r => r.id === currRowID);
  if (currentIndex < 0 || currentIndex >= tableData.length - 1) return;

  selectedRowHighlightID = tableData[currentIndex + 1].id;
} 

onPrevClick(): void {
  let currentIndex = tableData.findIndex(r => r.id === currRowID);
  if (currentIndex <= 0 ) return;

  selectedRowHighlightID = tableData[currentIndex - 1].id;
}

This approach ensures that there isn't unnecessary duplication or misinterpretation of context.

.page(current_page, page_size, request.query_params))

class Operate(APIView):
authentication_classes = [TokenAuth]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The provided code has some potential issues and can be optimized:

  1. Potential Error with query_params: The method .page() is supposed to accept pagination parameters like current_page and page_size. If these should come from request.data, it suggests that there might be an issue with how the data is being accessed or passed.

  2. Security Consideration: The use of TokenAuth for authentication in the Operate view does not provide any additional protection beyond what is necessary for API calls that don't involve sensitive operations. Ensure that other security measures (like Django's UserAuthentication) are in place if required for more secure access controls.

  3. Code Documentation: While not strictly a coding mistake, adding proper documentation comments to your methods would help clarify their purpose and usage.

Here’s a revised version of the code with some improvements:

from django.views import View
from rest_framework.request import Request
import serialization_module  # Assuming KnowledgeWorkflowActionSerializer lives here

class Page(View):
    def get(self, request: Request, workspace_id: str, knowledge_id: str, current_page: int, page_size: int):
        paginator = pagination.PageNumberPagination(page_size=page_size)
        serializer = serializers.KnowledgeWorkflowActionSerializer(data={
            'workspace_id': workspace_id,
            'knowledge_id': knowledge_id
        })
        
        queryset = serializer.get_queryset()
        paginated_queryset = paginator.paginate_queryset(queryset)

        return paginator.get_paginated_response(paginated_queryset)

class Operate(View):
    authentication_classes = [TokenAuthentication]  # Add Django authentication if needed

In this updated version:

  • I've assumed pagination.ModuleName.pagination.PageNumberPagination and serializers.module_name.KnowledgeWorkflowActionSerializer are correctly defined in your project.
  • The query set retrieval and pagination steps are now clearer to follow.
  • Basic authentication classes have been added for demonstration purposes; further customization may be needed based on project requirements.

Always ensure that any custom logic related to get_queryset() within the serializer is properly implemented and handles permissions and security appropriately.

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.

2 participants