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

Handling Missing Classifier IDs in PredictTicketClassificationService #5652

Open
paulo-rossy opened this issue Dec 20, 2024 · 1 comment
Open

Comments

@paulo-rossy
Copy link
Contributor

Handling Missing Classifier IDs in PredictTicketClassificationService

Description

Currently, an external service is used in the internal logic to predict the ticket classifier identifier. Here’s the relevant code from apps/condo/domains/ticket/schema/PredictTicketClassificationService.js:

const response = await fetch(endpoint, {
    headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json',
        'cookie': `authservice_session=${authKey}`,
        'x-workspace-id': workspace,
    },
    method: 'POST',
    body: JSON.stringify({ instances: [{ ticket: details }] }),
});
if (response.status !== 200) {
    throw new GQLError(ERRORS.TICKET_PREDICT_REQUEST_FAILED, context);
}
const result = await response.json();
const { prediction: [id] } = result;
const ticketClassifier = await getById('TicketClassifier', id);
if (!ticketClassifier) {
    throw new GQLError(ERRORS.TICKET_RULE_NOT_FOUND, context);
}
return ticketClassifier;

The external service is expected to take an array of string ticket descriptions as input and return an array of classifier IDs as output. However, there are cases where the ticket description may not match any classifier.

Current Behavior

  • If the id is missing in the response from the external service, the Ticket is not created.
  • This can lead to data loss since unmatched tickets are effectively discarded.

Expected Behavior

In cases where the external service cannot predict a TicketClassifier ID:

  1. Either the Ticket should be created without a classifier.
  2. Or a default classifier should be assigned.

This ensures that no ticket data is lost, even if the classifier cannot be determined.

Suggested Solution

  • Update the logic to handle cases where the id is missing or invalid:
    • If the predicted id is null or no TicketClassifier is found:
      • Either save the Ticket without a classifier.
      • Or assign a predefined default classifier ID.

Additional Context

This change will help prevent the loss of valuable data and provide a fallback for unmatched tickets. Let me know if additional details are needed!

@pahaz
Copy link
Member

pahaz commented Feb 19, 2025

Thank you for the question. It seems like a logical change. If the prediction identifier is not returned, we can create a ticket without it. Could you please create a PR?

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

No branches or pull requests

2 participants