cloudflare-go icon indicating copy to clipboard operation
cloudflare-go copied to clipboard

Wrong value returned in method: NewScanService

Open UtkarshSaxenautk opened this issue 7 months ago • 0 comments
trafficstars

Confirm this is a Go library issue and not an underlying Cloudflare API issue

  • [x] This is an issue with the Go library

Describe the bug

func (r *ScanService) New(ctx context.Context, params ScanNewParams, opts ...option.RequestOption) (res *string, err error) {
	var env ScanNewResponseEnvelope
	opts = append(r.Options[:], opts...)
	if params.AccountID.Value == "" {
		err = errors.New("missing required account_id parameter")
		return
	}
	path := fmt.Sprintf("accounts/%s/urlscanner/v2/scan", params.AccountID)
	err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...)
	if err != nil {
		return
	}
	res = &env.Result
	return
}

In this method it is expected to return UUID as mentioned in API which is to be used in methods like: ``Screenshot(ctx context.Context, scanID string, params ScanScreenshotParams, opts ...option.RequestOption) (res *http.Response, err error) Here currently it is returning a pointer to env.Result that is empty is mentioned in the response also.

`type ScanNewResponseEnvelope struct {
	// URL to api report.
	API     string `json:"api,required"`
	Message string `json:"message,required"`
	// URL to report.
	Result string `json:"result,required"`
	// Canonical form of submitted URL. Use this if you want to later search by URL.
	URL string `json:"url,required"`
	// Scan ID.
	UUID string `json:"uuid,required" format:"uuid"`
	// Submitted visibility status.
	Visibility string                         `json:"visibility,required"`
	Options    ScanNewResponseEnvelopeOptions `json:"options"`
	JSON       scanNewResponseEnvelopeJSON    `json:"-"`
}`

To Reproduce

  1. Call method to get ScanService: New(ctx context.Context, params ScanNewParams, opts ...option.RequestOption) (res *string, err error) This is expected to uuid (ScanID)
  2. Methods like Screeshot required ScanID that is uuid, but is inaccessible.

Code snippets


OS

linux

Go version

Go 1.24.0

Library version

https://github.com/cloudflare/cloudflare-go/blob/v4.2.0

UtkarshSaxenautk avatar Mar 27 '25 17:03 UtkarshSaxenautk