Skip to content

Follow-up use errors instead of errorMessage for Subscriptions::Security::PolicyProjectCreated

The following discussion from !158028 (merged) should be addressed:

  • @aturinske started a discussion: (+3 comments)

    @Andyschoenen why did you create the errorMessage field instead of using errors? errorMessage doesn't seem to trigger the error on the frontend?

    apollo: {
        $subscribe: {
          // eslint-disable-next-line @gitlab/vue-no-undef-apollo-properties
          newlyCreatedPolicyProject: {
            query() {
              return getSecurityPolicyProjectSub;
            },
            variables() {
              return { fullPath: this.namespacePath };
            },
            result({ data: { securityPolicyProjectCreated } }) {
              if (!securityPolicyProjectCreated) return;
    
    
              const { errorMessage, project } = securityPolicyProjectCreated;
    
              console.log('securityPolicyProjectCreated', securityPolicyProjectCreated);
              if (errorMessage) {
                throw new Error(errorMessage);
              }
    
              if (project) {
                this.currentAssignedPolicyProject = {
                  ...project,
                  branch: project?.branch?.rootRef,
                };
              }
            },
            error(e) {
              console.log(e);
              this.setError(e);
              this.setLoadingFlag(false);
            },
            skip() {
              return !this.glFeatures.securityPoliciesProjectBackgroundWorker;
            },
          },
        },
      },

Implementation plan

  1. Add errors to the securityPolicyProjectCreated subscription.
  2. Mark errorMessage as deprecated.
  3. Update frontend to use errors instead of errorMessage.
  4. Remove errorMessage.