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

Bug: QNA Seed field validation is broken for upload yaml #465

Open
nerdalert opened this issue Jan 10, 2025 · 0 comments
Open

Bug: QNA Seed field validation is broken for upload yaml #465

nerdalert opened this issue Jan 10, 2025 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@nerdalert
Copy link
Member

Recreate by uploading a valid qna.yaml. Add a taxonomy file path since that is not included in the qna.

Add debugging such as the following to validation.tsx to see the fields that are flagging invalid. It is QNA seed fields that Im seeing which are valid but not getting processed properly on a yaml upload/import:

export const checkKnowledgeFormCompletion = (knowledgeFormData: object): boolean => {
  // Helper function to check if a value is non-empty
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  const isNonEmpty = (value: any): boolean => {
    if (Array.isArray(value)) {
      return value.every((item) => isNonEmpty(item));
    }
    if (typeof value === 'object') {
      return checkObject(value);
    }
    return value !== undefined && value !== null && value !== '';
  };

  // Function to check if an object has all non-empty values
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  const checkObject = (obj: Record<string, any>): boolean => {
    return Object.keys(obj).every((key) => {
      const value = obj[key];
      const result = typeof value === 'object' && !Array.isArray(value) ? checkObject(value) : isNonEmpty(value);

      // Log field details for debugging
      if (!result) {
        console.log(`Field "${key}" is invalid. Value:`, value);
      }

      return result;
    });
  };

  return checkObject(knowledgeFormData);
};

Compare that with auto-fill and you will notice autofill sets the fields as valid. I would be for this for upload as well in the short term.

@nerdalert nerdalert added the help wanted Extra attention is needed label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant