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

Fix packages-public view function #5508

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dorbae
Copy link

@dorbae dorbae commented Sep 7, 2024

These changes make whisks.v.2.1/packges-public view function to check whether doc.binding is undfined before getting the length of it. It can prevent from CouchDB producing unnecessary logs.

Description

When 'packages-public' view builds the index, you can find these logs.

[info] 2024-09-07T02:25:38.312234Z nonode@nohost <0.1292.0> -------- OS Process #Port<0.8249> Log :: function raised exception (new TypeError("doc.binding is not an object", "undefined", 3)) with doc._id whisk.system/user25868/TEST

I modified 'isPublicPackage' function. I believe that use 'Falsy' because there's no need to check the length of doc.binding when it is not object type. And also, it's better to check Falsy or boolean before than the length of object.

// as-is
var isPublicPackage = functions(doc) {
    return Object.keys(doc.binding).length == 0 && doc.publish;
}

// to-be
var isPublicPackage = functions(doc) {
    return doc.binding && doc.publish && Object.keys(doc.binding).length == 0;
}

I confirmed that CouchDB 2.3.1 and 3.3.3 don't print it out during re-building the index.

Related issue and scope

My changes affect the following components

  • API
  • Controller
  • Message Bus (e.g., Kafka)
  • Loadbalancer
  • Scheduler
  • Invoker
  • Intrinsic actions (e.g., sequences, conductors)
  • Data stores (e.g., CouchDB)
  • Tests
  • Deployment
  • CLI
  • General tooling
  • Documentation

Types of changes

  • Bug fix (generally a non-breaking change which closes an issue).
  • Enhancement or new feature (adds new functionality).
  • Breaking change (a bug fix or enhancement which changes existing behavior).

Checklist:

  • I signed an Apache CLA.
  • I reviewed the style guides and followed the recommendations (Travis CI will check :).
  • I added tests to cover my changes.
  • My changes require further changes to the documentation.
  • I updated the documentation where necessary.

@rabbah
Copy link
Member

rabbah commented Sep 7, 2024

Thanks @dorbae for the fix

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

Successfully merging this pull request may close these issues.

2 participants